Loading

Quipoin Menu

Learn • Practice • Grow

node-js / Request & Response Objects
mcq
Direction: Choose the correct option

Q1.

What type of object is `req` in an HTTP server?
A. TransformStream
B. WritableStream
C. ReadableStream
D. DuplexStream
Direction: Choose the correct option

Q2.

Which method sets an HTTP header on the response?
A. res.setHeader()
B. res.writeHead()
C. res.header()
D. Both A and C
Direction: Choose the correct option

Q3.

How do you send a JSON response?
A. Use `res.json()`
B. Convert object to JSON with `JSON.stringify` and send
C. Both A and C
D. Set `Content-Type` header to `application/json`
Direction: Choose the correct option

Q4.

What is the purpose of `res.statusCode`?
A. To check if response is OK
B. To redirect
C. To get or set the HTTP status code
D. To log the status
Direction: Choose the correct option

Q5.

What does `res.write()` do?
A. Redirects the client
B. Ends the response
C. Sets a header
D. Writes a chunk of the response body