Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 2 MCQs Implementing HTTP Services & Basic Websites With Node.JS

INT222 — Advanced Web Development 50 questions. Pick an option to check it.

Read the notes

0 of 50 answered 0 right 0 wrong , 50 left

  1. Question 1 of 50

    Which built-in Node.js module is primarily used to create a web server?

  2. Question 2 of 50

    Which method of the HTTP module is used to initialize a server?

  3. Question 3 of 50

    What arguments does the request listener callback function in http.createServer() accept?

  4. Question 4 of 50

    Which method is used to make the Node.js HTTP server accept connections on a specific port?

  5. Question 5 of 50

    In a raw Node.js server, where is the request metadata (like headers and URL) stored?

  6. Question 6 of 50

    Which property of the request object holds the part of the URL after the domain name?

  7. Question 7 of 50

    Which method is used to send a chunk of the response body in the native HTTP module?

  8. Question 8 of 50

    What must be called to complete the response and send it to the client in the native HTTP module?

  9. Question 9 of 50

    How do you set the HTTP status code to 404 using the native response object?

  10. Question 10 of 50

    Which method is used to write the status code and response headers simultaneously in native Node.js?

  11. Question 11 of 50

    What is the correct HTTP status code for a successful request?

  12. Question 12 of 50

    What is the correct HTTP status code for 'Internal Server Error'?

  13. Question 13 of 50

    When sending JSON data using native Node.js, what should the 'Content-Type' header be set to?

  14. Question 14 of 50

    How is basic routing typically implemented in a native Node.js HTTP server?

  15. Question 15 of 50

    Which HTTP method is used to request data from a specified resource?

  16. Question 16 of 50

    Which HTTP method is commonly used to submit data to be processed to a specified resource?

  17. Question 17 of 50

    What is Express.js?

  18. Question 18 of 50

    Which command is used to install Express in a Node.js project?

  19. Question 19 of 50

    What is the first step to using Express in a file after installation?

  20. Question 20 of 50

    How do you initialize an Express application?

  21. Question 21 of 50

    Which Express method is used to handle GET requests?

  22. Question 22 of 50

    In Express, what method is used to send a response and automatically set the Content-Type?

  23. Question 23 of 50

    How do you access route parameters (e.g., /users/:id) in Express?

  24. Question 24 of 50

    How do you access query string parameters (e.g., ?search=term) in Express?

  25. Question 25 of 50

    Which Express method starts the server listening for connections?

  26. Question 26 of 50

    What is the purpose of 'body-parser' middleware?

  27. Question 27 of 50

    Before Express 4.16.0, body-parser was a separate install. How do you access JSON parsing now in modern Express?

  28. Question 28 of 50

    Which middleware parses incoming requests with URL-encoded payloads?

  29. Question 29 of 50

    If body-parser is not used, what is the value of req.body for a POST request in Express by default?

  30. Question 30 of 50

    What does the extended: true option in urlencoded() middleware do?

  31. Question 31 of 50

    What is express.Router used for?

  32. Question 32 of 50

    How do you expose a router defined in a separate file?

  33. Question 33 of 50

    How do you mount a router module in the main app file?

  34. Question 34 of 50

    If you mount a router at '/api', and the router has a route for '/users', what is the full path?

  35. Question 35 of 50

    Which library is commonly used with Express for validating incoming request data?

  36. Question 36 of 50

    In express-validator, which function is used to validate a field in the request body?

  37. Question 37 of 50

    What does validationResult(req) return in express-validator?

  38. Question 38 of 50

    Which method in express-validator is used to check if a field is a valid email?

  39. Question 39 of 50

    What is the purpose of sanitization in express-validator?

  40. Question 40 of 50

    Where do you place the validation middleware in an Express route definition?

  41. Question 41 of 50

    In express-validator, how do you check if the validation result contains errors?

  42. Question 42 of 50

    Which of the following matches a route path for ANY HTTP method in Express?

  43. Question 43 of 50

    What is a 'middleware' in the context of Express?

  44. Question 44 of 50

    What does the next argument represent in an Express middleware function?

  45. Question 45 of 50

    Which status code indicates 'Bad Request' due to validation failure?

  46. Question 46 of 50

    How do you chain multiple validators on the same field in express-validator?

  47. Question 47 of 50

    In a native Node server, how do you differentiate between a POST and a GET request?

  48. Question 48 of 50

    What is the primary advantage of using Express over the native HTTP module?

  49. Question 49 of 50

    Which method allows you to serve static files (images, CSS) in Express?

  50. Question 50 of 50

    When setting a custom response header in Express, which method is used?

That's unit 2

Answer a few questions and your score shows up here.