Learn Node Js MCQs

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

How do you handle errors in asynchronous code in Node.js?

1) Using `try/catch` with `async/await` or `.catch()` with Promises

2) Using synchronous error handling

3) By ignoring errors

4) By logging errors only

Answer : Option 1

What is the purpose of the `process.nextTick()` method?

1) To schedule a callback to be executed in the next iteration of the event loop

2) To execute a function immediately

3) To handle asynchronous operations

4) To manage file systems

Answer : Option 1

How do you handle file uploads in Express.js?

1) Using middleware like `multer`

2) Using `fs` module

3) Using `http` module

4) Using `formidable` module

Answer : Option 1

What is the `fs.access()` method used for?

1) To check if a file or directory exists and has specified permissions

2) To read a file

3) To write to a file

4) To delete a file

Answer : Option 1

How do you generate and use UUIDs in Node.js?

1) By using the `uuid` module

2) By using the `crypto` module

3) By using the `random` module

4) By using `Math.random()`

Answer : Option 1

What is the purpose of the `util.promisify()` function?

1) To convert callback-based functions into Promise-based functions

2) To handle asynchronous code

3) To manage file systems

4) To parse URLs

Answer : Option 1

How do you manage your Node.js application s dependencies?

1) By using `package.json` and `npm` or `yarn`

2) By using `requirements.txt`

3) By using `dependencies` file

4) By using `project.json`

Answer : Option 1

What is the role of the `domain` module in Node.js?

1) To handle errors and manage domains of execution

2) To manage file systems

3) To handle HTTP requests

4) To work with streams

Answer : Option 1

How do you handle rate limiting in Node.js?

1) By using middleware like `express-rate-limit`

2) By using custom code

3) By using the `http` module

4) By using the `fs` module

Answer : Option 1

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

1) To handle compression and decompression of data

2) To manage file systems

3) To handle HTTP requests

4) To parse URLs

Answer : Option 1