Rahul Vijayan
Follow for more updates
TCS Wings 1 T1 MERN - Set 9
- Leo is developing a MongoDB query to find documents where the
age
field is greater than 25. Which MongoDB operator should he use?
- a)
$gte
- b)
$gt
- c)
$lt
- d)
$eq
Answer: b) $gt
- Harper wants to set default values for
props
in a React component. Which approach should she use?
- a)
propTypes
- b)
defaultProps
- c)
initialState
- d)
useEffect
Answer: b) defaultProps
- Oliver is creating an Express route that should handle both GET and POST requests to the same endpoint. Which Express method allows him to handle multiple HTTP methods in one route?
- a)
app.all
- b)
app.use
- c)
app.route
- d)
app.listen
Answer: c) app.route
- Ava needs to run a function only after the first render of a React component. Which dependency array should she pass to
useEffect
?
- a)
[variable]
- b)
[state]
- c)
[]
- d)
[props]
Answer: c) []
- Mason is building a MongoDB query to include only documents where a
status
field equals"active"
. Which operator will help him filter documents based on this exact match?
- a)
$match
- b)
$eq
- c)
$in
- d)
$exists
Answer: b) $eq
- Lucas wants to avoid re-rendering a React component when certain state values change in a parent component. Which hook will help him control re-renders efficiently?
- a)
useEffect
- b)
useMemo
- c)
useCallback
- d)
React.memo
Answer: d) React.memo
- Emma is using MongoDB’s
$project
stage in her aggregation pipeline. What is the main purpose of$project
?
- a) Filter documents
- b) Sort documents
- c) Select specific fields
- d) Group documents
Answer: c) Select specific fields
- Jack wants to ensure his Express app handles asynchronous errors properly. Which pattern helps him wrap route functions to handle asynchronous errors effectively?
- a)
try-catch
in each route - b) Global error middleware
- c) Async wrapper function
- d) Using
finally
Answer: c) Async wrapper function
- Isla is designing a MongoDB query that should return the number of documents that match a certain criterion. Which MongoDB method will help her achieve this?
- a)
countDocuments
- b)
find
- c)
aggregate
- d)
limit
Answer: a) countDocuments
- Oliver is implementing pagination in MongoDB to retrieve a limited number of documents at a time. Which two methods will help him implement this feature?
- a)
skip
andlimit
- b)
project
andgroup
- c)
findOne
andfind
- d)
sort
andaggregate
Answer: a) skip
and limit
No comments:
Post a Comment