Monday, October 28, 2024

TCS Wings 1 T1 MERN - Set 10

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 10


  1. Noah is adding a custom middleware to check for a user’s role before accessing specific routes in Express. Where should he place this middleware in the route definitions?
  • a) Before route handler functions
  • b) After route handler functions
  • c) Inside the database configuration
  • d) In app.listen

Answer: a) Before route handler functions


  1. Mia wants her React component to update only when a specific state variable changes, avoiding unnecessary re-renders. Which hook should she use?
  • a) useEffect
  • b) useRef
  • c) useCallback
  • d) useMemo

Answer: a) useEffect


  1. Ava is testing CRUD operations on an Express API endpoint using a tool that sends HTTP requests. Which tool is commonly used for this purpose?
  • a) MongoDB Atlas
  • b) Postman
  • c) Visual Studio Code
  • d) JSON Server

Answer: b) Postman


  1. Ethan needs to merge multiple arrays in MongoDB, removing duplicate values in the final result. Which aggregation operator should he use?
  • a) $merge
  • b) $addToSet
  • c) $push
  • d) $project

Answer: b) $addToSet


  1. Olivia is creating a new document in MongoDB and wants the _id field to be auto-generated. How does MongoDB handle the _id field by default when inserting new documents?
  • a) Generates automatically
  • b) Requires manual input
  • c) Must be generated in the application code
  • d) Is optional for insertion

Answer: a) Generates automatically


  1. Grace wants to add offline capabilities to her React PWA so it can load without internet. Which technology should she implement?
  • a) LocalStorage
  • b) Session Storage
  • c) Service Workers
  • d) Redux

Answer: c) Service Workers


  1. Leo needs his Express server to send JSON data to a client request. Which method should he use to send JSON?
  • a) res.send
  • b) res.write
  • c) res.json
  • d) res.end

Answer: c) res.json


  1. Harper is performing an aggregation in MongoDB and needs to ensure only documents matching a specific condition are passed to the next stage. Which stage will help her?
  • a) $match
  • b) $project
  • c) $group
  • d) $lookup

Answer: a) $match


  1. Amelia wants to display the same component multiple times with different data based on an array in React. Which approach allows her to iterate over the array and render the component for each item?
  • a) forEach
  • b) map
  • c) filter
  • d) find

Answer: b) map


  1. Lucas is storing a sensitive token in his React app and wants to prevent it from being accessed through JavaScript. Where is the best place to store the token?
  • a) Local Storage
  • b) Session Storage
  • c) httpOnly Cookies
  • d) Redux

Answer: c) httpOnly Cookies 

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