Create New Post

Node JS MCQs - 10

  1. What is the purpose of the res.type() method in Express.js?

    • A) To set the HTTP status code of the response
    • B) To set the content type of the response
    • C) To send an HTTP response with JSON data
    • D) To send an HTTP response with HTML content

    Answer: B) To set the content type of the response

  2. In Express.js, what is the purpose of the req.app property?

    • A) To access the application settings
    • B) To access the request headers
    • C) To access the route object
    • D) To access the base URL of the application

    Answer: A) To access the application settings

  3. Which of the following middleware is commonly used for logging in Express.js?

    • A) express.json()
    • B) express.static()
    • C) morgan
    • D) express-session

    Answer: C) morgan

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

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

    Answer: A) To send a JSON response with padding

  5. In Express.js, what does the req.subdomains property contain?

    • A) The request method
    • B) The request headers
    • C) An array of subdomains in the domain name
    • D) The route object

    Answer: C) An array of subdomains in the domain name

  6. What is the purpose of the res.attachment() method in Express.js?

    • A) To set the HTTP status code of the response
    • B) To attach a file to the response
    • C) To send an HTTP response with JSON data
    • D) To send an HTTP response with HTML content

    Answer: B) To attach a file to the response

  7. In Express.js, what is the purpose of the req.xhr property?

    • A) To check if the request is an XMLHttpRequest
    • B) To access the request headers
    • C) To access the route object
    • D) To access the base URL of the application

    Answer: A) To check if the request is an XMLHttpRequest

  8. Which of the following Express.js methods is used to handle HTTP TRACE requests?

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

    Answer: A) app.trace()

  9. What is the purpose of the res.end() method in Express.js?

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

    Answer: B) To end the response process

  10. In Express.js, what is the purpose of the req.route.path property?
    - A) To access the request method

    - B) To access the request headers
    - C) To access the route path pattern
    - D) To access the route object

    Answer: C) To access the route path pattern
     

Comments

Leave a Reply

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

41850