Create New Post

Node JS MCQs - 7

  1. What is the purpose of the req.query object in Express.js?

    • A) To access request query parameters
    • B) To access request headers
    • C) To access URL route parameters
    • D) To access request body parameters

    Answer: A) To access request query parameters

  2. In Express.js, what does the app.locals object do?

    • A) Stores application-wide data accessible in all views
    • B) Stores request-specific data accessible in middleware
    • C) Provides access to request query parameters
    • D) Manages session data for users

    Answer: A) Stores application-wide data accessible in all views

  3. Which Express.js method is used to handle HTTP DELETE requests?

    • A) app.delete()
    • B) app.put()
    • C) app.get()
    • D) app.post()

    Answer: A) app.delete()

  4. What is the purpose of the res.status() method in Express.js?

    • A) To set the HTTP status code of the response
    • B) To send an HTTP response with JSON data
    • C) To send an HTTP response with HTML content
    • D) To redirect the client to a new URL

    Answer: A) To set the HTTP status code of the response

  5. Which of the following Express.js methods is used to mount a router on a route path?

    • A) app.use()
    • B) app.route()
    • C) router.use()
    • D) router.route()

    Answer: A) app.use()

  6. Which of the following Express.js methods is used to handle HTTP PUT requests?

    • A) app.put()
    • B) app.get()
    • C) app.post()
    • D) app.delete()

    Answer: A) app.put()

  7. What is the purpose of middleware in Express.js?

    • A) To define routes for handling HTTP requests
    • B) To handle database operations
    • C) To manipulate request and response objects
    • D) To render views with data

    Answer: C) To manipulate request and response objects

  8. What does MVC stand for in the context of web development?

    • A) Model View Controller
    • B) Maximum Volume Control
    • C) Most Valuable Code
    • D) Minimal View Complexity

    Answer: A) Model View Controller

  9. In Express.js, which method is used to handle HTTP PATCH requests?

    • A) app.patch()
    • B) app.put()
    • C) app.post()
    • D) app.delete()

    Answer: A) app.patch()

  10. What is the purpose of the req.headers object in Express.js?

    • A) To access request query parameters
    • B) To access request headers
    • C) To access URL route parameters
    • D) To access request body parameters

    Answer: B) To access request headers

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

58319