Rahul Vijayan
Follow for more updates
TCS Wings 1 T1 MERN - Set 4
- Mason is using MongoDB and needs to filter documents by a field value. Which method should he use to filter data within the MongoDB collection?
- a)
aggregate
- b)
find
- c)
sort
- d)
group
Answer: b) find
- Isla is optimizing her React app by using
useCallback
to memoize a function that gets called in auseEffect
. What doesuseCallback
specifically help prevent?
- a) Prevents component unmounting
- b) Prevents unnecessary re-renders of a function
- c) Prevents memory leaks
- d) Prevents updating the state
Answer: b) Prevents unnecessary re-renders of a function
- Oliver is using Express and wants to set up a route that requires authentication. Which status code should he return if a user tries to access it without being logged in?
- a) 200
- b) 401
- c) 404
- d) 500
Answer: b) 401
- Grace wants to apply custom error handling to an asynchronous route in her Express app. What should she use to catch errors in asynchronous functions?
- a)
try-catch
block - b)
await
- c)
setTimeout
- d)
throw
Answer: a) try-catch
block
- Leo is fetching data from an API in his React component using
useEffect
. He notices the data fetch runs on every render. What is the correct way to fetch data only once when the component mounts?
- a) Add
[]
as the dependency array inuseEffect
- b) Call the API directly in the component body
- c) Use
useMemo
instead ofuseEffect
- d) Use
useCallback
Answer: a) Add []
as the dependency array in useEffect
- Ava is using MongoDB to store data and wants to update multiple documents that match a specific condition. Which MongoDB method should she use?
- a)
update
- b)
updateOne
- c)
updateMany
- d)
replaceOne
Answer: c) updateMany
- Charlie is working with a large dataset in MongoDB and needs to limit the number of documents returned by a query. Which MongoDB method should he use to achieve this?
- a)
limit
- b)
aggregate
- c)
sort
- d)
group
Answer: a) limit
- Ella wants to serve a PWA on her website, so it’s installable on mobile devices. Which file is required to set up a PWA?
- a)
manifest.json
- b)
index.html
- c)
style.css
- d)
app.js
Answer: a) manifest.json
- Liam is using Express with middleware to handle request data in JSON format. Where should he place the middleware in his Express app for it to parse JSON?
- a) Before route definitions
- b) After route definitions
- c) Only in error-handling routes
- d) Inside each route definition
Answer: a) Before route definitions
- Emily is using MongoDB and needs to count the number of documents that match certain criteria. Which method should she use?
- a)
countDocuments
- b)
find
- c)
aggregate
- d)
distinct
Answer: a) countDocuments
No comments:
Post a Comment