Learn Node Js MCQs

Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.

What is the purpose of the `debug` module in Node.js?

1) To provide debugging utilities

2) To manage logging

3) To handle HTTP requests

4) To validate inputs

Answer : Option 1

How do you define a middleware function in Express.js?

1) app.use()

2) app.route()

3) app.get()

4) app.post()

Answer : Option 1

What is the `res.redirect()` method used for in Express.js?

1) To redirect the client to a different URL

2) To send a JSON response

3) To render a view

4) To handle file uploads

Answer : Option 1

How do you install a specific version of a package using npm?

1) npm install @

2) npm install

3) npm install

4) npm install

Answer : Option 1

Which Node.js function is used to parse JSON data?

1) JSON.parse()

2) parse.json()

3) JSON.decode()

4) json.parse()

Answer : Option 1

What does `npm cache clean` do?

1) Clears the npm cache

2) Updates the npm cache

3) Installs a package

4) Removes a package

Answer : Option 1

How do you handle multipart form data in Node.js?

1) Using middleware like multer

2) Using custom code

3) Using `fs` module

4) Using `querystring` module

Answer : Option 1

What does the `res.send()` method do in Express.js?

1) Sends a response to the client

2) Sets response headers

3) Redirects the client

4) Handles form submissions

Answer : Option 1

Which method is used to create a new directory in Node.js?

1) fs.mkdir()

2) fs.createDirectory()

3) fs.openDirectory()

4) fs.newDirectory()

Answer : Option 1

What is the purpose of the `http` module in Node.js?

1) To create and handle HTTP requests and responses

2) To manage file systems

3) To parse URLs

4) To handle streams

Answer : Option 1