Loading

Quipoin Menu

Learn • Practice • Grow

node-js / Creating HTTP Server
mcq
Direction: Choose the correct option

Q1.

Which method creates an HTTP server in Node.js?
A. http.newServer()
B. http.createServer()
C. http.Server()
D. http.start()
Direction: Choose the correct option

Q2.

What does the request listener function receive?
A. Only the request
B. A request and response object
C. A callback
D. Only the response
Direction: Choose the correct option

Q3.

How do you make the server listen on a port?
A. server.listen(3000)
B. server.start(3000)
C. server.run(3000)
D. server.open(3000)
Direction: Choose the correct option

Q4.

What is the default hostname if not specified in `server.listen()`?
A. 0.0.0.0
B. 127.0.0.1
C. localhost
D. ::
Direction: Choose the correct option

Q5.

What does `res.end('Hello')` do?
A. Sends the response and ends the connection
B. Logs 'Hello' to console
C. Redirects to another page
D. Sets a header