Monday, October 28, 2024

TCS Wings 1 T1 MERN - Set 3

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 3 


  1. Ethan is working with MongoDB and needs to perform an aggregation to calculate the average price of products in each category. Which MongoDB pipeline stage should he use?
  • a) $group
  • b) $match
  • c) $sort
  • d) $project

Answer: a) $group


  1. Amelia has created a form in her React app to add new items to her MongoDB collection through an Express API. Which HTTP method should she use for this request?
  • a) GET
  • b) POST
  • c) PUT
  • d) DELETE

Answer: b) POST


  1. Lucas wants to prevent his React component from re-rendering when a prop changes. Which hook should he use to memoize the component to prevent unnecessary renders?
  • a) useEffect
  • b) useCallback
  • c) useMemo
  • d) React.memo

Answer: d) React.memo


  1. Mia is designing a MongoDB query to find all products with a price greater than $100. Which operator will help her achieve this?
  • a) $lt
  • b) $gt
  • c) $ne
  • d) $in

Answer: b) $gt


  1. Liam has a PWA and wants it to load as a fullscreen app when launched from the home screen on mobile. Which attribute in the manifest.json file will help him achieve this?
  • a) display
  • b) theme_color
  • c) background_color
  • d) orientation

Answer: a) display


  1. Sofia is optimizing her Express app by adding middleware for logging. Which popular middleware package can she use for this purpose?
  • a) morgan
  • b) body-parser
  • c) cors
  • d) helmet

Answer: a) morgan


  1. Ryan wants to ensure his MongoDB collections are accessible only to authenticated users in his Express app. Which middleware is best suited to protect routes requiring authentication?
  • a) Logging middleware
  • b) Authorization middleware
  • c) Error-handling middleware
  • d) Static middleware

Answer: b) Authorization middleware


  1. Harper is implementing a feature in her React app that updates based on a prop change. Which hook will allow her to respond to the prop change in a controlled way?
  • a) useState
  • b) useEffect
  • c) useCallback
  • d) useMemo

Answer: b) useEffect


  1. Noah is building a Node.js app and wants to handle JSON data in incoming requests. Which Express middleware should he add?
  • a) express.static
  • b) express.json
  • c) express.urlencoded
  • d) body-parser

Answer: b) express.json


  1. Ava has an API call in her React component and wants to avoid rendering it twice when the component mounts. Which dependency array setup should she use in useEffect?
  • a) []
  • b) [props]
  • c) [state]
  • d) useEffect without array

Answer: a) []

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