Learn Node Js MCQs
Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of the `Buffer` class in Node.js?
1) To handle binary data
2) To store string data
3) To manage HTTP requests
4) To handle files
Answer : Option 1
Which Node.js method is used to handle HTTP responses?
1) res.send()
2) req.receive()
3) http.response()
4) http.send()
Answer : Option 1
How do you handle incoming data in a POST request?
1) Using req.body
2) Using req.query
3) Using req.params
4) Using req.headers
Answer : Option 1
Which module is used to create and manage streams in Node.js?
1) stream
2) fs
3) http
4) events
Answer : Option 1
What does `npm start` typically do?
1) Runs the start script defined in package.json
2) Installs packages
3) Starts a new project
4) Executes a script
Answer : Option 1
How do you create a new file in Node.js?
1) fs.writeFile()
2) fs.createFile()
3) fs.open()
4) fs.appendFile()
Answer : Option 1
What is the purpose of the `await` keyword in Node.js?
1) To wait for a Promise to resolve
2) To handle errors
3) To execute synchronous code
4) To read files
Answer : Option 1
Which module helps you handle URL parsing in Node.js?
1) url
2) path
3) querystring
4) http
Answer : Option 1
How do you handle events in Node.js?
1) Using the EventEmitter class
2) Using callback functions
3) Using promises
4) Using async/await
Answer : Option 1
What is the purpose of the `res.json()` method in Express.js?
1) To send a JSON response
2) To parse JSON data
3) To handle HTTP headers
4) To read query parameters
Answer : Option 1