Monday, October 28, 2024

TCS Wings 1 T1 MERN - Set 7

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 7


  1. Mason wants to handle asynchronous errors in his Express routes without using try-catch blocks in every route. Which helper function pattern can streamline this process?
  • a) Middleware chaining
  • b) Wrapper function that returns a promise
  • c) Logging middleware
  • d) Error-handler in route itself

Answer: b) Wrapper function that returns a promise


  1. Harper is using MongoDB's $aggregate to calculate the total number of items in each category. Which stage allows her to group data by a category field?
  • a) $match
  • b) $project
  • c) $group
  • d) $sort

Answer: c) $group


  1. Noah is using axios to fetch data in his React component and notices a CORS error in the console. What should he configure in the Express server to resolve this?
  • a) Enable body-parser
  • b) Use the cors middleware
  • c) Use the helmet package
  • d) Change the HTTP method

Answer: b) Use the cors middleware


  1. Grace wants her React component to run a specific function only when a dependency array value changes. Which hook will help her achieve this?
  • a) useState
  • b) useEffect
  • c) useMemo
  • d) useCallback

Answer: b) useEffect


  1. Oliver is updating a document in MongoDB and wants only one field to be modified while leaving the rest unchanged. Which MongoDB operator should he use?
  • a) $set
  • b) $push
  • c) $pull
  • d) $unset

Answer: a) $set


  1. Ella wants her React component to store some data that should only reset when the component unmounts. Which React feature will help her achieve this?
  • a) useState
  • b) useEffect
  • c) useRef
  • d) useContext

Answer: c) useRef


  1. Ava wants to ensure a middleware runs on every request to her Express server. Where should she place this middleware in her server configuration?
  • a) Before all route definitions
  • b) After all route definitions
  • c) Inside each route handler
  • d) Inside app.listen

Answer: a) Before all route definitions


  1. Lucas is developing a CRUD API using Express and MongoDB. Which HTTP method is used to delete a specific document based on an ID in a RESTful API?
  • a) POST
  • b) PUT
  • c) DELETE
  • d) GET

Answer: c) DELETE


  1. Amelia is using MongoDB and wants to delete multiple documents that match a specific criterion. Which method should she use?
  • a) delete
  • b) deleteOne
  • c) deleteMany
  • d) remove

Answer: c) deleteMany


  1. Ethan is setting up an API in Express that requires authentication. Which HTTP status code should he return if the user provides invalid credentials?
  • a) 200
  • b) 403
  • c) 401
  • d) 404

Answer: c) 401 

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