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 

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 

TCS Wings 1 T1 MERN - Set 8

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 8


  1. Mia is creating a dynamic list in React and wants each list item to have a unique identifier to avoid warning messages. Which attribute should she assign to each item?
  • a) ref
  • b) id
  • c) className
  • d) key

Answer: d) key


  1. Jack is implementing a sorting feature in MongoDB that arranges documents by a field in ascending order. Which value should he pass to the sort method to achieve this?
  • a) 1
  • b) -1
  • c) $asc
  • d) $desc

Answer: a) 1


  1. Sofia is handling CRUD operations in her Express app. Which method should she use to update a specific field in an existing document in MongoDB?
  • a) insertOne
  • b) updateOne
  • c) deleteOne
  • d) findOne

Answer: b) updateOne


  1. Ryan needs to call an API in his React app and wants the call to occur only once when the component mounts. What should he use as the dependency array for useEffect?
  • a) [props]
  • b) [state]
  • c) []
  • d) undefined

Answer: c) []


  1. Isla is using MongoDB and wants to limit her query results to only 10 documents. Which MongoDB method allows her to control the number of results?
  • a) skip
  • b) limit
  • c) count
  • d) filter

Answer: b) limit


  1. Mason is developing a PWA and wants the app to be available offline. Which browser feature allows his app to cache assets for offline access?
  • a) Local Storage
  • b) Service Worker
  • c) Session Storage
  • d) IndexedDB

Answer: b) Service Worker


  1. Ava wants to retrieve only specific fields from documents in a MongoDB collection. Which MongoDB method allows her to control which fields are returned?
  • a) find
  • b) select
  • c) project
  • d) limit

Answer: c) project


  1. Ethan wants to perform an aggregation in MongoDB that calculates the maximum value of a field in each group. Which operator should he use within the $group stage?
  • a) $sum
  • b) $avg
  • c) $max
  • d) $min

Answer: c) $max


  1. Mia is using axios to post data to an API and wants to handle both success and error responses. Which method allows her to catch errors from the API response?
  • a) .then()
  • b) .get()
  • c) .catch()
  • d) .finally()

Answer: c) .catch()


  1. Ella needs to pass data from a parent React component to its child component. Which React concept should she use?
  • a) State
  • b) Props
  • c) Context
  • d) Lifecycle

Answer: b) Props 

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 

TCS Wings 1 T1 MERN - Set 6

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 6 


  1. Jake is using MongoDB to group documents by a field and calculate the total sum of another field within each group. Which aggregation pipeline stage should he use?
  • a) $sum
  • b) $group
  • c) $match
  • d) $project

Answer: b) $group


  1. Ava is implementing a search filter in her MongoDB collection where she wants to retrieve documents that match any one of several values for a given field. Which MongoDB operator will help her achieve this?
  • a) $and
  • b) $in
  • c) $or
  • d) $eq

Answer: b) $in


  1. Lucas wants to add an Express middleware that logs every request method and URL. Where should he place the middleware for it to log each request globally?
  • a) After defining routes
  • b) Before defining routes
  • c) Inside each route
  • d) Inside the server.js file only

Answer: b) Before defining routes


  1. Amelia needs to display a large list of items in a React component without slowing down the UI. Which React feature can help her optimize rendering performance?
  • a) useEffect
  • b) useCallback
  • c) Virtual DOM
  • d) Component Lifecycle

Answer: c) Virtual DOM


  1. Ethan wants to render different components in his React app based on specific URL paths. Which library is commonly used to handle routing in React?
  • a) Axios
  • b) react-router-dom
  • c) Express
  • d) MongoDB

Answer: b) react-router-dom


  1. Mia is setting up server-side validation in her Express app to prevent users from submitting invalid data. Which Express feature allows her to handle validation errors centrally?
  • a) Route handlers
  • b) Middleware
  • c) Controllers
  • d) Database

Answer: b) Middleware


  1. Sofia wants to sort documents in her MongoDB collection by the date in descending order. Which MongoDB method allows her to sort documents by a specified field?
  • a) find
  • b) sort
  • c) update
  • d) aggregate

Answer: b) sort


  1. Ryan wants to store the user authentication token on the client side and make it accessible across page reloads. Which storage option is recommended for sensitive tokens in a PWA?
  • a) Local Storage
  • b) Session Storage
  • c) httpOnly Cookies
  • d) IndexedDB

Answer: c) httpOnly Cookies


  1. Isla needs to display a loading message while waiting for data to be fetched from an API in her React component. Which state should she use to track this process?
  • a) useEffect
  • b) loading
  • c) isLoading
  • d) data

Answer: c) isLoading


  1. Leo is debugging an Express route that returns a 404 error when he tries to access it. Which method should he use to verify that the route matches the URL and HTTP method correctly?
  • a) app.post
  • b) app.put
  • c) app.use
  • d) app.get

Answer: d) app.get

TCS Wings 1 T1 MERN - Set 5

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 5 


  1. Jack is designing an API using Express and wants to secure routes with token-based authentication. Which middleware is best suited for validating tokens?
  • a) cors
  • b) helmet
  • c) Custom middleware that checks for valid tokens
  • d) express.static

Answer: c) Custom middleware that checks for valid tokens


  1. Chloe needs to pass a function as a prop to a child component in React. Which data type should she use in the prop?
  • a) Object
  • b) Function
  • c) String
  • d) Array

Answer: b) Function


  1. Ethan is using Express to build a REST API and wants to return JSON data. Which method should he use to send JSON responses?
  • a) res.write
  • b) res.end
  • c) res.sendFile
  • d) res.json

Answer: d) res.json


  1. Mia has a list of items displayed in a React component. She wants to ensure each item has a unique key to avoid rendering issues. Which attribute should she use for each item?
  • a) id
  • b) ref
  • c) key
  • d) className

Answer: c) key


  1. Alex needs to store user session data on the client side for a PWA. Which storage method is recommended for sensitive information like tokens?
  • a) Local Storage
  • b) Session Storage
  • c) Cookies with httpOnly and Secure flags
  • d) IndexedDB

Answer: c) Cookies with httpOnly and Secure flags


  1. Sara wants to perform an operation in MongoDB to retrieve documents where a certain field exists. Which operator should she use?
  • a) $exists
  • b) $in
  • c) $gte
  • d) $lte

Answer: a) $exists


  1. Liam is handling errors globally in his Express app. What should he pass as the first argument to the error-handling middleware function?
  • a) req
  • b) res
  • c) error
  • d) next

Answer: c) error


  1. Emma is optimizing her API calls with Axios in React and wants to cancel an API request if the component unmounts. Which method will allow her to achieve this?
  • a) AbortController
  • b) Promise.all
  • c) useMemo
  • d) React.memo

Answer: a) AbortController


  1. Noah is implementing a search function in MongoDB that performs case-insensitive searches. Which MongoDB feature will help him achieve this?
  • a) $regex
  • b) $text
  • c) $caseSensitive
  • d) $group

Answer: a) $regex


  1. Lily is handling form validation in her React app and wants to display an error message if a user leaves an input field blank. Which method is commonly used for client-side validation in React?
  • a) window.alert
  • b) setState
  • c) input validation with controlled components
  • d) console.log

Answer: c) input validation with controlled components

TCS Wings 1 T1 MERN - Set 4

Rahul Vijayan
Follow for more updates

TCS Wings 1 T1 MERN - Set 4 

  1. Mason is using MongoDB and needs to filter documents by a field value. Which method should he use to filter data within the MongoDB collection?
  • a) aggregate
  • b) find
  • c) sort
  • d) group

Answer: b) find


  1. Isla is optimizing her React app by using useCallback to memoize a function that gets called in a useEffect. What does useCallback specifically help prevent?
  • a) Prevents component unmounting
  • b) Prevents unnecessary re-renders of a function
  • c) Prevents memory leaks
  • d) Prevents updating the state

Answer: b) Prevents unnecessary re-renders of a function


  1. Oliver is using Express and wants to set up a route that requires authentication. Which status code should he return if a user tries to access it without being logged in?
  • a) 200
  • b) 401
  • c) 404
  • d) 500

Answer: b) 401


  1. Grace wants to apply custom error handling to an asynchronous route in her Express app. What should she use to catch errors in asynchronous functions?
  • a) try-catch block
  • b) await
  • c) setTimeout
  • d) throw

Answer: a) try-catch block


  1. Leo is fetching data from an API in his React component using useEffect. He notices the data fetch runs on every render. What is the correct way to fetch data only once when the component mounts?
  • a) Add [] as the dependency array in useEffect
  • b) Call the API directly in the component body
  • c) Use useMemo instead of useEffect
  • d) Use useCallback

Answer: a) Add [] as the dependency array in useEffect


  1. Ava is using MongoDB to store data and wants to update multiple documents that match a specific condition. Which MongoDB method should she use?
  • a) update
  • b) updateOne
  • c) updateMany
  • d) replaceOne

Answer: c) updateMany


  1. Charlie is working with a large dataset in MongoDB and needs to limit the number of documents returned by a query. Which MongoDB method should he use to achieve this?
  • a) limit
  • b) aggregate
  • c) sort
  • d) group

Answer: a) limit


  1. Ella wants to serve a PWA on her website, so it’s installable on mobile devices. Which file is required to set up a PWA?
  • a) manifest.json
  • b) index.html
  • c) style.css
  • d) app.js

Answer: a) manifest.json


  1. Liam is using Express with middleware to handle request data in JSON format. Where should he place the middleware in his Express app for it to parse JSON?
  • a) Before route definitions
  • b) After route definitions
  • c) Only in error-handling routes
  • d) Inside each route definition

Answer: a) Before route definitions


  1. Emily is using MongoDB and needs to count the number of documents that match certain criteria. Which method should she use?
  • a) countDocuments
  • b) find
  • c) aggregate
  • d) distinct

Answer: a) countDocuments

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

TCS Wings 1 T1 MERN - Set 2

Rahul Vijayan
Follow for more updates


TCS Wings 1 T1 MERN - Set 2 

  1. Leo is developing a Node.js API and needs to handle large JSON payloads. Which middleware should he add to his Express app?
  • a) express.static
  • b) express.urlencoded
  • c) express.json
  • d) body-parser

Answer: c) express.json


  1. Emily is using useState in her React component to handle form data. Which statement correctly updates the state without mutating the existing state object?
  • a) setState({ name: 'Emily' })
  • b) setState((prevState) => ({ ...prevState, name: 'Emily' }))
  • c) setState = { name: 'Emily' }
  • d) setState(name: 'Emily')

Answer: b) setState((prevState) => ({ ...prevState, name: 'Emily' }))


  1. Arjun is building a feature to allow users to update their profiles. Which HTTP method should he use for this operation in his Express app?
  • a) GET
  • b) POST
  • c) PUT
  • d) DELETE

Answer: c) PUT


  1. Sara is building a component that fetches and displays a user’s profile. She wants the component to refetch data every time the userId prop changes. Which setup should she use in useEffect?
  • a) useEffect(() => {}, [])
  • b) useEffect(() => { fetchData(); }, [userId])
  • c) useEffect(() => { fetchData(); }, [fetchData])
  • d) useEffect(fetchData, [userId])

Answer: b) useEffect(() => { fetchData(); }, [userId])


  1. Ben wants to aggregate and group documents in MongoDB by a specific field. Which MongoDB method will help him achieve this?
  • a) find
  • b) sort
  • c) aggregate
  • d) mapReduce

Answer: c) aggregate


  1. Emma is designing a React component that updates its style dynamically based on state. Which method is the most React-appropriate way to apply styles conditionally?
  • a) Use inline styles with a ternary operator.
  • b) Use an if-else statement directly in the JSX.
  • c) Use a CSS file with conditional class names.
  • d) Write CSS styles in a separate JavaScript function.

Answer: a) Use inline styles with a ternary operator.


  1. Jordan is trying to make his Node.js application scale well. What strategy could he use to handle high traffic efficiently?
  • a) Increase the number of GET requests
  • b) Use clustering or worker threads to handle multiple requests simultaneously
  • c) Increase the memory available to the Node.js application
  • d) Rewrite the code in another language

Answer: b) Use clustering or worker threads to handle multiple requests simultaneously


  1. Lisa wants to ensure that her Express app has a global error handler. Which middleware placement will ensure this?
  • a) At the beginning of her middleware stack
  • b) Just after defining all routes
  • c) Inside the router
  • d) Inside each route handler

Answer: b) Just after defining all routes


  1. Martin has a React app that interacts with a Node.js backend. He wants to handle failed API requests due to network errors. Which approach should he take?
  • a) Log the error to the console
  • b) Use a try-catch block with Axios requests
  • c) Add retries for each Axios request
  • d) Refresh the page after each error

Answer: b) Use a try-catch block with Axios requests


  1. Olivia is designing an Express app with user authentication. Which middleware will help her protect routes from unauthorized access?
  • a) Static middleware
  • b) Logging middleware
  • c) Authentication middleware
  • d) Error-handling middleware

Answer: c) Authentication middleware

TCS Wings 1 T1 MERN - Set 1

Rahul Vijayan
Follow for more updates


TCS Wings 1 T1 MERN - Set 1

  1. James is working on a React application. He notices that after a certain update, the state isn't updating as expected when using the useState hook. Which of the following is the most likely cause?
    • a) James is not updating the state directly in the component function.
    • b) James is mutating the state directly instead of using the setter function returned by useState.
    • c) James is using useEffect to trigger the state update.
    • d) James is using multiple useState hooks, which are overwriting each other.
    Answer: b) James is mutating the state directly instead of using the setter function returned by useState.

  1. Lily is implementing a function in her React component to fetch data from an API. She wants this to happen only once when the component mounts. Which lifecycle hook should she use to achieve this?
    • a) componentDidUpdate
    • b) useEffect with an empty dependency array
    • c) useState
    • d) componentWillUnmount
    Answer: b) useEffect with an empty dependency array

  1. Sam is building a login form in React and is using Axios to call a REST API endpoint. He’s noticing that the request is sent twice every time he submits the form. What might be the reason?

    • a) Sam is using the useEffect hook incorrectly, causing it to rerun.
    • b) Sam has accidentally called the function twice in the button’s onClick handler.
    • c) Sam’s form is submitting both via onClick and the form’s submit event.
    • d) Sam is not using Axios correctly.

    Answer: c) Sam’s form is submitting both via onClick and the form’s submit event.


  1. Maya wants to add a feature where her Express app logs each incoming request. Which middleware function should she use to achieve this?
    • a) Error-handling middleware
    • b) Route-level middleware
    • c) Application-level middleware
    • d) next() middleware
    Answer: c) Application-level middleware

  1. Adam is working with MongoDB and needs to retrieve documents sorted by a specific field. Which method will help him achieve this?

    • a) sort
    • b) aggregate
    • c) find
    • d) filter

    Answer: a) sort


  1. Priya needs to display a list of items in her React app with sorting and filtering options. Which hook would be most useful to update the UI when sorting criteria change?
    • a) useRef
    • b) useEffect
    • c) useMemo
    • d) useCallback
    Answer: b) useEffect

  1. Ethan wants to optimize his Express app to handle static files efficiently. Which built-in middleware should he use?
    • a) app.use('/static', express.static())
    • b) app.use(express.json())
    • c) app.use(express.urlencoded())
    • d) app.use('/files', express.static())
    Answer: a) app.use('/static', express.static())

  1. Nina is using React components to create a list of user profiles from an API. Which lifecycle hook should she use to fetch the data when the component mounts?

    • a) useLayoutEffect
    • b) useEffect
    • c) useState
    • d) useMemo

    Answer: b) useEffect


  1. Daniel is creating a form that submits data to his Express server. Which HTTP method should he use to submit the data if he wants to create a new resource?
    • a) GET
    • b) POST
    • c) PUT
    • d) DELETE
    Answer: b) POST

  1. Sophia is working on a PWA for offline functionality. Which API should she use to cache assets and data for offline access?
  • a) Fetch API
  • b) Service Worker API
  • c) Local Storage
  • d) Session Storage

Answer: b) Service Worker API

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