Learn Node Js MCQs
Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.
What does the `util.format()` function do?
1) Logs data to the console
2) Handles asynchronous operations
3) Parses JSON data
4) Formats a string using placeholders
Answer : Option 4
How do you create a symbolic link in Node.js?
1) By using the `http` module
2) By using the `os` module
3) By using the `tls` module
4) By using the `fs.symlink()` method
Answer : Option 4
What is the purpose of the `vm` module in Node.js?
1) To handle file systems
2) To create HTTP servers
3) To manage child processes
4) To create and manage virtual machines
Answer : Option 4
How do you parse command-line arguments in Node.js?
1) Using `process.env`
2) Using `require()`
3) Using `path.join()`
4) Using `process.argv`
Answer : Option 4
What is the purpose of `Buffer.alloc()`?
1) To allocate a new buffer of a specified size
2) To concatenate multiple buffers
3) To compare two buffers
4) To convert a buffer to a string
Answer : Option 1
How do you create a Readable stream in Node.js?
1) Using `stream.Readable` class
2) Using `stream.Writable` class
3) Using `stream.Transform` class
4) Using `fs.createReadStream()`
Answer : Option 4
What does `http.Agent` manage in Node.js?
1) Connection pooling for HTTP clients
2) Handling of incoming requests
3) Processing of outgoing responses
4) Parsing of URL parameters
Answer : Option 1
How do you handle errors in a promise chain?
1) By using `.catch()`
2) By using `.then()`
3) By using `.finally()`
4) By using `try...catch`
Answer : Option 1
What is the default behavior of `require()` in Node.js?
1) It caches the module after the first time it is loaded
2) It loads the module fresh every time
3) It blocks the event loop until the module is loaded
4) It only works with core modules
Answer : Option 1
How do you make an HTTP GET request using Node.js?
1) Using `http.get()`
2) Using `http.createServer()`
3) Using `http.request()`
4) Using `http.fetch()`
Answer : Option 1