Monday, October 28, 2024

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

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