Learn Node Js MCQs
Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.
What is the `app.listen()` method used for in Express.js?
1) To start the server and listen on a specified port
2) To handle HTTP requests
3) To define routes
4) To manage middleware
Answer : Option 1
How do you handle CORS (Cross-Origin Resource Sharing) in Node.js?
1) By using the `cors` middleware
2) By setting headers manually
3) By configuring the server
4) By modifying request parameters
Answer : Option 1
What does the `npm outdated` command do?
1) Lists outdated packages in your project
2) Updates packages
3) Installs new packages
4) Removes packages
Answer : Option 1
How do you perform a GET request in Node.js?
1) Using the `http` module
2) Using the `request` module
3) Using the `fetch` API
4) Using the `axios` library
Answer : Option 1
What is the purpose of the `debug` package in Node.js?
1) To enable debug logging
2) To handle HTTP requests
3) To manage file systems
4) To parse JSON data
Answer : Option 1
How do you test a Node.js application?
1) Using testing frameworks like Mocha or Jest
2) Using manual testing
3) Using integration testing tools
4) Using system monitoring tools
Answer : Option 1
What is the `npm ci` command used for?
1) To install dependencies from a package-lock.json file
2) To update packages
3) To run scripts
4) To clear npm cache
Answer : Option 1
How do you handle session management in Node.js?
1) Using session middleware like `express-session`
2) Using `body-parser`
3) Using `cookie-parser`
4) Using `morgan`
Answer : Option 1
What does the `fs.stat()` method return?
1) Information about a file or directory
2) The contents of a file
3) The file name
4) The file path
Answer : Option 1
How do you use the `buffer` module in Node.js?
1) To work with binary data
2) To manage file systems
3) To handle HTTP requests
4) To parse URLs
Answer : Option 1