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 3 MCQs Socket Services in Node.js & Creating middlewares

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

    What is the primary communication protocol used by WebSockets?

  2. Question 2 of 50

    Which URL scheme is used for an unencrypted WebSocket connection?

  3. Question 3 of 50

    Unlike HTTP, a WebSocket connection is:

  4. Question 4 of 50

    Which HTTP header is essential for the WebSocket handshake process?

  5. Question 5 of 50

    In a basic Node.js 'ws' server, which event is triggered when a client connects?

  6. Question 6 of 50

    Which method is used to send a message from the server to a specific client instance in the 'ws' library?

  7. Question 7 of 50

    What does Socket.IO provide that native WebSockets do not handle automatically?

  8. Question 8 of 50

    In Socket.IO, how do you send a message to all connected clients?

  9. Question 9 of 50

    Which Socket.IO method is used to send a message to everyone except the sender?

  10. Question 10 of 50

    In Express.js, what is 'middleware'?

  11. Question 11 of 50

    What is the purpose of the 'next' function in Express middleware?

  12. Question 12 of 50

    Which Express method is used to mount middleware functions at a specific path?

  13. Question 13 of 50

    What does app.all('/api/*', ...) do?

  14. Question 14 of 50

    What is the primary purpose of the cookie-parser middleware?

  15. Question 15 of 50

    Where does cookie-session store the session data?

  16. Question 16 of 50

    Where does express-session store the session data by default?

  17. Question 17 of 50

    Which option allows Socket.IO clients to join a specific channel or 'room'?

  18. Question 18 of 50

    In Socket.IO, how do you send a message only to clients in a specific room?

  19. Question 19 of 50

    What argument is required to initialize cookie-parser if you want to use signed cookies?

  20. Question 20 of 50

    When using express-session, which property is added to the request object?

  21. Question 21 of 50

    Which express-session option forces the session to be saved back to the store, even if it wasn't modified?

  22. Question 22 of 50

    In middleware, what happens if you call next() with an error argument, like next(new Error('Fail'))?

  23. Question 23 of 50

    What is the signature of a standard Express error-handling middleware function?

  24. Question 24 of 50

    To serve static files such as images or CSS files in Express, which built-in middleware is used?

  25. Question 25 of 50

    Which library is the client-side counterpart to the Node.js 'socket.io' package?

  26. Question 26 of 50

    In a WebSocket 'message' event, the data received is typically:

  27. Question 27 of 50

    Which cookie-session option helps prevent Cross-Site Scripting (XSS) attacks by preventing client-side scripts from accessing the cookie?

  28. Question 28 of 50

    If you want middleware to run for every request to the application, how should you mount it?

  29. Question 29 of 50

    What is the default name of the cookie used by express-session to store the session ID?

  30. Question 30 of 50

    In Socket.IO, what is a 'Namespace'?

  31. Question 31 of 50

    How do you access signed cookies in Express if cookie-parser is set up with a secret?

  32. Question 32 of 50

    Which method removes a specific session in express-session?

  33. Question 33 of 50

    When using app.use(bodyParser.json()), what does this middleware do?

  34. Question 34 of 50

    In Socket.IO, what does the volatile flag do? e.g., socket.volatile.emit(...)

  35. Question 35 of 50

    What is the main disadvantage of cookie-session compared to express-session?

  36. Question 36 of 50

    Which event is fired in Socket.IO when a client disconnects?

  37. Question 37 of 50

    How can you limit middleware to a specific HTTP verb (e.g., POST) for a specific path?

  38. Question 38 of 50

    What is a 'room' in Socket.IO primarily used for?

  39. Question 39 of 50

    If you want to persist login state across server restarts effectively, which session store should you use with express-session?

  40. Question 40 of 50

    What is the output of typeof req.session inside a route handler when using express-session?

  41. Question 41 of 50

    Which middleware would you use to log details of every incoming request (method, URL, etc.)?

  42. Question 42 of 50

    In a WebSocket connection, what property indicates the current state (connecting, open, closing, closed)?

  43. Question 43 of 50

    When initializing express-session, what does the saveUninitialized: false option do?

  44. Question 44 of 50

    Which function allows multiple middleware functions to be applied to a single route?

  45. Question 45 of 50

    In Socket.IO, socket.id represents:

  46. Question 46 of 50

    If you wish to send binary data (like an image) via ws library, what type of data should you pass to .send()?

  47. Question 47 of 50

    What is the purpose of the 'secret' used in session middleware?

  48. Question 48 of 50

    Can middleware modify the req and res objects?

  49. Question 49 of 50

    In a Chat Server, why would you store socket.id mapped to a username?

  50. Question 50 of 50

    What happens if you attempt to use req.body without installing and using a body-parsing middleware (like express.json())?

That's unit 3

Answer a few questions and your score shows up here.