Node.js Objective Type Quiz & MCQs with Answers for Interview Preparation | Gyansetu

Gyansetu Team Data Science, Others
Node.js Course

Practice these MCQs to strengthen your Node.js knowledge and prepare confidently for job interviews or certification exams.
Whether you’re aiming to become a backend specialist, a full-stack developer, or simply sharpen your skills in asynchronous programming, REST APIs, and server-side JavaScript — you’re in the right place.
70+ Node.js MCQs covering everything from core modules, file systems, Express.js, middleware, events, asynchronous operations, and advanced concepts — complete with answers to help you test and solidify your understanding, no guesswork involved.

Section 1: Node.js Basics – 10 MCQs

  1. What is Node.js?
    A. JavaScript framework
    B. Programming language
    C. JavaScript runtime built on Chrome’s V8 engine
    D. Web server
    Answer: C
  2. Which of the following is true about Node.js?
    A. It’s synchronous by default
    B. It uses event-driven, non-blocking I/O
    C. It is compiled directly to machine code
    D. It only runs on Windows
    Answer: B
  3. Which command is used to initialize a Node.js project?
    A. npm init
    B. node start
    C. node init
    D. npm install
    Answer: A
  4. Which of the following is NOT a global object in Node.js?
    A. __dirname
    B. window
    C. require
    D. process
    Answer: B
  5. What will this code output?

console.log(typeof null);

A. null
B. object
C. undefined
D. string
Answer: B

  1. Which module is used to create a server in Node.js?
    A. fs
    B. http
    C. server
    D. path
    Answer: B
  2. How can you import a built-in module in Node.js?
    A. import fs from ‘fs’
    B. include(‘fs’)
    C. require(‘fs’)
    D. use(‘fs’)
    Answer: C
  3. What will the following code do?

console.log(__dirname);

A. Print the directory name of the file
B. Print the file content
C. Print the current timestamp
D. Throw an error
Answer: A

.NET MVC course

Master Node.js Interviews with Confidence – Quiz Your Way to Success

  1. What is the use of process.exit()?
    A. Restart the script
    B. Exit the Node.js process
    C. Pause the process
    D. Run in a loop
    Answer: B
  2. Which of the following is NOT a core module?
    A. fs
    B. express
    C. http
    D. path
    Answer: B

Section 2: Modules & NPM – 10 MCQs

  1. What is NPM?
    A. Node Programming Method
    B. Node Package Manager
    C. Network Process Manager
    D. Node Parser Module
    Answer: B
  2. Which file lists project dependencies?
    A. package.json
    B. node_modules
    C. npm.config
    D. server.js
    Answer: A
  3. How do you install a package globally?
    A. npm install package-name
    B. npm install -g package-name
    C. npm get package-name
    D. npm global package-name
    Answer: B
  4. What does npm update do?
    A. Uninstalls packages
    B. Updates the npm tool
    C. Updates all packages
    D. Upgrades Node.js
    Answer: C
  5. Which keyword exports a module in Node.js?
    A. return
    B. exports
    C. module.exports
    D. require
    Answer: C
  6. Which statement is correct?

module.exports = { add: function(a, b) { return a + b; } }

A. Exporting a function
B. Exporting an object
C. Invalid syntax
D. A and B
Answer: D

  1. What is the purpose of require() in Node.js?
    A. Define a class
    B. Load modules
    C. Create an HTTP request
    D. Encrypt passwords
    Answer: B
  2. What does npm init -y do?
    A. Launch server
    B. Generate default package.json
    C. Install yarn
    D. Open index.js
    Answer: B
  3. What folder stores installed packages locally?
    A. lib_modules
    B. modules
    C. node_modules
    D. npm_files
    Answer: C
  4. How can you uninstall a Node package?
    A. npm delete <package>
    B. npm remove <package>
    C. npm uninstall <package>
    D. npm clean <package>
    Answer: C

Section 3: File System & Events – 10 MCQs

  1. Which method reads a file asynchronously?
    A. fs.read()
    B. fs.readFileSync()
    C. fs.readFile()
    D. fs.loadFile()
    Answer: C
  2. Which event is emitted when a stream ends?
    A. close
    B. finish
    C. end
    D. stop
    Answer: C
  3. What does this code do?

const fs = require(‘fs’);

fs.writeFileSync(‘test.txt’, ‘Hello World’);

A. Writes file asynchronously
B. Appends to file
C. Writes file synchronously
D. Reads file
Answer: C

  1. Which core module handles events?
    A. fs
    B. eventManager
    C. events
    D. process
    Answer: C
.NET MVC course

Level Up Your Node.js Skills with Interactive MCQs

  1. How do you emit a custom event?

emitter.emit(‘start’);

A. True
B. False
Answer: A

  1. Which method creates an event listener?
    A. on()
    B. emit()
    C. listen()
    D. event()
    Answer: A
  2. What will happen if an error event has no listener?
    A. Node ignores it
    B. Node logs it
    C. Node throws an exception
    D. Node retries
    Answer: C
  3. What is the default encoding for reading files?
    A. ASCII
    B. Binary
    C. UTF-8
    D. ISO
    Answer: C
  4. Which method deletes a file?
    A. fs.remove()
    B. fs.deleteFile()
    C. fs.unlink()
    D. fs.delete()
    Answer: C
  5. Which module is required for file path operations?
    A. os
    B. url
    C. dir
    D. path
    Answer: D

Section 4: Express.js – 10 MCQs

  1. What is Express.js?
    A. Frontend framework
    B. Database driver
    C. Web application framework for Node.js
    D. JavaScript compiler
    Answer: C
  2. Which command installs Express?
    A. npm get express
    B. npm add express
    C. npm install express
    D. node install express
    Answer: C
  3. Which code sets up a basic Express server?

const express = require(‘express’);

const app = express();

app.listen(3000);

A. True
B. False
Answer: A

  1. What method handles GET requests in Express?
    A. app.fetch()
    B. app.get()
    C. app.req()
    D. app.retrieve()
    Answer: B
  2. Which is the correct way to send a response?

res.send(‘Hello World’);

A. True
B. False
Answer: A

  1. What does req.params access?
    A. Query parameters
    B. Route parameters
    C. Form data
    D. Headers
    Answer: B
  2. How do you parse JSON bodies in Express?
    A. app.use(express.json())
    B. app.json()
    C. express.parseJSON()
    D. req.body.json()
    Answer: A
  3. Which middleware handles form submissions?
    A. express.urlencoded()
    B. express.forms()
    C. app.useForms()
    D. express.body()
    Answer: A
  4. Which status code represents a successful POST request?
    A. 200
    B. 201
    C. 404
    D. 500
    Answer: B
  5. How to define a dynamic route in Express?

app.get(‘/user/:id’, …)

A. True
B. False
Answer: A


Section 5: APIs & Middleware – 10 MCQs

  1. What is middleware in Express?
    A. A database layer
    B. A route handler
    C. A function executed between request and response
    D. A frontend component
    Answer: C
  2. Which method registers middleware globally?
    A. app.add()
    B. app.route()
    C. app.use()
    D. middleware()
    Answer: C
  3. What does the next() function do in middleware?
    A. Stops execution
    B. Sends response
    C. Passes control to the next middleware
    D. Returns JSON
    Answer: C
  4. Which response method sends JSON data?
    A. res.send()
    B. res.end()
    C. res.json()
    D. res.stringify()
    Answer: C
  5. What is a REST API?
    A. Database
    B. Server-side tool
    C. Architectural style for APIs
    D. JavaScript framework
    Answer: C
  6. Which HTTP method is used to update resources?
    A. GET
    B. PUT
    C. PATCH
    D. Both B and C
    Answer: D
  7. What does this middleware do?

app.use((req, res, next) => {

  console.log(req.url);

  next();

});

A. Logs requests
B. Blocks requests
C. Sends response
D. Loads files
Answer: A

  1. How do you serve static files in Express?

app.use(express.static(‘public’));

A. True
B. False
Answer: A

49. Which status code means unauthorized access?
A. 401
B. 403
C. 400
D. 404
Answer: A

.NET MVC course

Code Less, Practice More – Crack Node.js Interviews Easily!

  1. What does CORS stand for?
    A. Core Object Routing System
    B. Cross-Origin Resource Sharing
    C. Conditional Origin Request Setup
    D. Content Optimization Routing Strategy
    Answer: B

Section 6: Asynchronous Programming – 10 MCQs

  1. What is a callback?
    A. A variable
    B. A function passed into another function
    C. A loop
    D. A file
    Answer: B
  2. What is the purpose of async keyword?
    A. Pause function
    B. Make function synchronous
    C. Enable use of await
    D. Define a promise
    Answer: C
  3. What does await do?
    A. Blocks other processes
    B. Waits for a promise to resolve
    C. Speeds up execution
    D. Caches response
    Answer: B
  4. Which module is used for promises in Node.js?
    A. promises
    B. util
    C. promiseHandler
    D. No module needed
    Answer: D
  5. Which function converts callback-based functions to promises?
    A. util.promisify()
    B. Promise.from()
    C. awaitify()
    D. callbackToPromise()
    Answer: A
  6. What will this return?

Promise.resolve(5).then(x => console.log(x));

A. Error
B. 5
C. undefined
D. 0
Answer: B

  1. Which of the following methods handles multiple promises?
    A. Promise.combine()
    B. Promise.all()
    C. Promise.chain()
    D. Promise.loop()
    Answer: B
  2. Which Node.js function is asynchronous?
    A. fs.readFile()
    B. fs.readFileSync()
    C. JSON.parse()
    D. require()
    Answer: A
  3. Which tool helps manage async operations better than callbacks?
    A. setTimeout()
    B. Promises
    C. console.log()
    D. fs module
    Answer: B
  4. What is callback hell?
    A. Multiple async functions nested inside each other
    B. Infinite loops
    C. Memory leak
    D. Server crash
    Answer: A

Section 7: Error Handling & Advanced Topics – 10 MCQs

  1. How do you handle errors in async/await?
    A. try…catch
    B. throw error()
    C. handle()
    D. error()
    Answer: A
  2. What does this code do?

throw new Error(‘Something went wrong’);

A. Creates a warning
B. Returns status code
C. Stops execution
D. Logs to console
Answer: C

  1. What is the default port for Node.js apps (if not specified)?
    A. 8080
    B. 3000
    C. 80
    D. 5000
    Answer: B
  2. Which method listens for server connections in Express?
    A. connect()
    B. server()
    C. listen()
    D. respond()
    Answer: C
  3. Which of these is NOT an error handling middleware in Express?
    A. (err, req, res, next)
    B. function errorHandler(err)
    C. (req, res)
    D. customErrorHandler(err, req, res, next)
    Answer: C
  4. What is the use of cluster module in Node.js?
    A. Monitor servers
    B. Create sub-processes
    C. Run multiple instances of Node.js for load balancing
    D. Schedule tasks
    Answer: C
  5. Which command checks for outdated packages?
    A. npm check
    B. npm outdated
    C. npm status
    D. npm validate
    Answer: B
  6. What will process.env.NODE_ENV usually be set to in production?
    A. prod
    B. development
    C. production
    D. env
    Answer: C
  7. What does dotenv package do?
    A. Connects to database
    B. Stores credentials in .env file
    C. Handles authentication
    D. Validates HTTP requests
    Answer: B
  8. Which of the following is a benefit of using Node.js?
    A. Blocking I/O
    B. Slow performance
    C. Scalable and fast for I/O-heavy applications
    D. Built-in GUI
    Answer: C
.NET MVC course

Smart Learning for Smart Coders – Node.js MCQs that Work.

Mastering these Node.js MCQs is a valuable step toward building a strong foundation in backend development, RESTful APIs, asynchronous programming, and server-side logic.
If you’re ready to elevate your career with hands-on projects and expert-led instruction, join our Node.js course in Gurgaon at Gyansetu and become industry-ready for high-demand backend and full-stack development roles.

Gyansetu Team

Leave a Comment

Your email address will not be published. Required fields are marked *

Categories
Web Development/ Languages
Java Course
4959 reviews
Next Batch - 3 Jan, 2026
3 months Online/ Offline
Android App Development Course
5687 reviews
Next Batch - 4 Jan, 2026
3 months Online/ Offline
Best Django Course
4568 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Best Java Spring 5 Training
2568 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Data Structures and Algorithms Certification Program
Best Data Structures And Algorithms Course gurgaon​
6897 reviews
Next Batch - 10 Jan, 2026
4 months Online/ Offline
Java Spring5 (Boot and Micro Services) Training in Gurgaon
236 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
C/C++ Programming Training in Gurgaon
428 reviews
Next Batch - 4 Jan, 2026
3 months Online/ Offline
Teach your Kids to Code | Python for Elementary Students
678 reviews
Next Batch - 10 Jan, 2026
2 months Online/ Offline
Java 8 Frameworks Training courses-Spring | Hibernate | Webservices
317 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Java Training In Gurgaon | Core and Advanced Java Programming Course
495 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Python Language Framework Django Training in Gurgaon,Delhi
435 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Dot NET MVC Training in Gurgaon
258 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Dot Net Core Training in Gurgaon
308 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Android Training In Gurgaon | Mobile App Development Training
283 reviews
Next Batch - 4 Jan, 2026
3 months Online/ Offline
Java Course
4959 reviews
Next Batch - 3 Jan, 2026
3 months Online/ Offline
Android App Development Course
5687 reviews
Next Batch - 4 Jan, 2026
3 months Online/ Offline
Best Django Course
4568 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Best Java Spring 5 Training
2568 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Data Structures and Algorithms Certification Program
Best Data Structures And Algorithms Course gurgaon​
6897 reviews
Next Batch - 10 Jan, 2026
4 months Online/ Offline
Java Spring5 (Boot and Micro Services) Training in Gurgaon
236 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
C/C++ Programming Training in Gurgaon
428 reviews
Next Batch - 4 Jan, 2026
3 months Online/ Offline
Teach your Kids to Code | Python for Elementary Students
678 reviews
Next Batch - 10 Jan, 2026
2 months Online/ Offline
Java 8 Frameworks Training courses-Spring | Hibernate | Webservices
317 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Java Training In Gurgaon | Core and Advanced Java Programming Course
495 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Python Language Framework Django Training in Gurgaon,Delhi
435 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Dot NET MVC Training in Gurgaon
258 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Dot Net Core Training in Gurgaon
308 reviews
Next Batch - 10 Jan, 2026
3 months Online/ Offline
Android Training In Gurgaon | Mobile App Development Training
283 reviews
Next Batch - 4 Jan, 2026
3 months Online/ Offline
Drop us a Query
+91-9999201478

Available 24x7 for your queries

Please enable JavaScript in your browser to complete this form.