Monday, October 28, 2024

TCS Wings 1 T1 MERN - Set 9

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 9


  1. 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


  1. 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


  1. 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


  1. 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) []


  1. 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


  1. 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


  1. 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


  1. 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


  1. 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


  1. 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 and limit
  • b) project and group
  • c) findOne and find
  • d) sort and aggregate

Answer: a) skip and limit 

No comments:

Post a Comment

TCS Wings 1 T1 MERN - Set 10

Rahul Vijayan Follow for more updates TCS Wings 1 T1 MERN - Set 10 Noah is adding a custom middleware to check for a user’s role before acce...