Test Your Node.js Knowledge: Multiple Choice Questions (MCQ)
Challenge your understanding of Node.js with this set of multiple-choice questions. This quiz covers core concepts, modules, and best practices, providing a fun and effective way to assess your Node.js expertise.
Node.js Multiple Choice Questions (MCQ)
Introduction
This section presents multiple-choice questions (MCQs) covering various aspects of Node.js. These questions test your understanding of core concepts, modules, and common development practices.
Multiple Choice Questions
- Which of the following statements is correct about Node.js?
- Node.js is a server-side language.
- Node.js is a client-side language.
- Node.js is both server-side and client-side.
- None of the above.
A is correct. Node.js is primarily a server-side runtime environment.
- What does REPL stand for?
- Read Eval Print Loop
- Research Eval Program Learn
- Read Earn Point Learn
- Read Eval Point Loop
A is correct. REPL stands for Read-Eval-Print Loop.
- Which command starts a REPL session?
node
node start
node repl
node console
A is correct. Simply running
node
in your terminal starts the REPL. - Node.js is written in:
- JavaScript
- C
- C++
- CoffeeScript
- All of the above
- How do you install the Express.js module?
npm install express
node install express
install express
- None of the above
- What is a callback function?
- A function that calls another function.
- An asynchronous function equivalent.
- Both of the above
- None of the above
- Node.js files typically use which extension?
.js
.node
.java
.txt
- How are Node.js modules exposed?
expose
module
exports
- All of the above
- Which of these is NOT a built-in Node.js module?
zlib
https
dgram
fsread
- Which `fs` module method gets file information?
fs.open()
fs.stat()
fs.readFile()
- None of the above
- What does the `fs` module stand for?
- File Service
- File System
- File Store
- File Sharing
- Which `fs` method truncates a file?
fs.delete()
fs.remove()
fs.ftruncate()
- None of the above
- A template engine usable with Node.js is:
- Jade
- Vash
- Handlebars
- All of the above
- Which code snippet prints the operating system platform?
console.log('platform : ' + os.platform);
console.log('platform : ' + os.platform());
console.log('platform : ' + os.getPlatform());
- None of the above
- Which method gets the current working directory?
cwd()
cwd()
pwd()
- None of the above
- What best describes Express.js?
- A framework for desktop apps.
- A minimal and flexible Node.js web application framework.
- Both of the above.
- None of the above.
- Which is NOT a benefit of Express.js modules?
- Task separation.
- Code reuse.
- Reduced program size.
- Easier testing.
- A best practice for performance optimization is:
- Using gzip compression.
- Avoiding synchronous functions.
- Proper logging.
- Effective exception handling.
- The default scope in Node.js is:
- Global
- Local
- Global Function
- Local to object
- Node.js uses which JavaScript engine?
- Chrome V8
- Microsoft Chakra
- SpiderMonkey
- Node Engine
- How do you run a file named `sample.js`?
sample.js
node sample.js
nodejs sample.js
- None of the above
- Which is NOT a valid language for Node.js?
- JavaScript
- Java
- C
- C++
- What's the shortcut to kill a Node.js process?
- Ctrl + B
- Ctrl + K
- Ctrl + T
- Ctrl + C
- How many object methods are in Node.js's `os` module?
- 21
- 18
- 19
- 20
- The main use of Node.js's REPL is:
- Application preview.
- Testing expressions.
- Executing browser JavaScript.
- None of the above.
- What application types can Node.js build?
- Web applications
- Chat applications
- RESTful services
- All of the above
- Which operator checks node equality?
==
equal()
isEqualNode()
- None of the above
- Which tool automates Node.js tasks?
- Express.js
- GruntJS
- npm
- None of the above
- When is Node.js NOT recommended?
- Single-page applications
- JSON API applications
- CPU-intensive applications
- Real-time applications
- Which is a valid Express.js route parameter format?
/books/!:from-:to
/flights/:from-:to
/users/:userId/books/:bookId
E is correct. Node.js uses a combination of languages.
A is correct.
B is correct. A callback is primarily used for asynchronous operations.
A is correct.
C is correct. Use module.exports
.
D is correct.
B is correct. fs.stat()
provides file statistics.
B is correct. `fs` stands for File System.
C is correct.
D is correct. Many templating engines work with Node.js.
B is correct. Use os.platform()
.
A is correct. Use process.cwd()
.
B is correct.
C is correct. Modules don't directly reduce program size.
While all are good practices, A (gzip compression) directly impacts performance.
B is correct. Variables are typically locally scoped unless declared globally.
A is correct.
B is correct.
B is correct. Node.js primarily uses JavaScript.
D is correct.
B is correct (This might need verification based on the specific Node.js version).
B is correct.
D is correct.
C is correct (This depends on the context; `isEqualNode()` is common in DOM APIs).
B is correct. GruntJS is a popular task runner.
C is correct. Node.js is not ideal for CPU-bound tasks.
While all *could* work depending on the implementation, C is the most standard and recommended format.
- Which statement is correct about Node.js?
- It's a server-side language.
- It's a client-side language.
- It's both server-side and client-side.
- None of the above.
- What does REPL stand for?
- Read Eval Print Loop
- Research Eval Program Learn
- Read Earn Point Learn
- Read Eval Point Loop
- How do you start a REPL session?
node
node start
node repl
node console
- Node.js is written in:
- JavaScript
- C
- C++
- CoffeeScript
- All of the above
- The command to install the Express.js module is:
npm install express
node install express
install express
- None of the above
- What is a callback function in Node.js?
- A function calling another function.
- An asynchronous function equivalent.
- Both of the above.
- None of the above.
- Node.js files typically use this extension:
.js
.node
.java
.txt
- Node.js modules are exposed using:
expose
module
exports
- All of the above
- Which is NOT a built-in Node.js module?
zlib
https
dgram
fsread
- The `fs` module method for file information is:
fs.open()
fs.stat()
fs.readFile()
- None of the above
- What does the `fs` module stand for?
- File Service
- File System
- File Store
- File Sharing
- The `fs` method to truncate a file is:
fs.delete()
fs.remove()
fs.ftruncate()
- None of the above
- Which template engine works with Node.js?
- Jade
- Vash
- Handlebars
- All of the above
- Which code gets the OS platform?
console.log('platform : ' + os.platform);
console.log('platform : ' + os.platform());
console.log('platform : ' + os.getPlatform());
- None of the above
- Which method returns the current working directory?
cwd()
cwd()
pwd()
- None of the above
- What is Express.js?
- A framework for desktop apps.
- A minimal and flexible Node.js web application framework.
- Both of the above.
- None of the above.
- Which is NOT a benefit of using modules in Express.js?
- Improved code organization.
- Code reusability.
- Reduced program size.
- Improved testability.
- A top practice for Node.js application performance is:
- Using gzip compression.
- Avoiding synchronous functions.
- Proper logging.
- Effective error handling.
- What is the default scope in Node.js?
- Global
- Local
- Global Function
- Local to object
- Node.js uses which core JavaScript engine?
- Chrome V8
- Microsoft Chakra
- SpiderMonkey
- Node Engine
- How do you run a file named `sample.js`?
sample.js
node sample.js
nodejs sample.js
- None of the above
- Which is NOT a valid language for Node.js?
- JavaScript
- Java
- C
- C++
- The Node.js process kill shortcut is:
- Ctrl + B
- Ctrl + K
- Ctrl + T
- Ctrl + C
- How many methods are in Node.js's `os` module? (This may vary by version)
- 21
- 18
- 19
- 20
- The main use of Node.js's REPL is:
- Previewing applications.
- Testing expressions.
- Executing browser JavaScript.
- None of the above.
- What application types can Node.js build?
- Web Applications
- Chat Applications
- RESTful Services
- All of the above
- Which operator checks for node equality (in a DOM context)?
==
equal()
isEqualNode()
- None of the above
- Which tool automates Node.js tasks?
- Express.js
- GruntJS
- npm
- None of the above
- When is Node.js less suitable?
- Single-page apps
- JSON APIs
- CPU-intensive tasks
- Real-time apps
- Which is a standard Express.js route parameter format?
/books/!:from-:to
/flights/:from-:to
/users/:userId/books/:bookId
A is correct. Node.js is primarily server-side.
A is correct.
A is correct. Just type node
in your terminal.
E is correct. It's a combination of languages.
A is correct.
B is the best answer, focusing on its asynchronous nature.
A is correct.
C is correct. Use module.exports
.
D is correct.
B is correct.
B is correct.
C is correct.
D is correct; many templating engines are available.
B is correct.
A is correct. Use process.cwd()
.
B is correct.
C is correct. Modules don't guarantee smaller program size.
While all are important, A directly improves speed.
B is correct. Local scope is preferred.
A is correct.
B is correct.
B is correct. Node.js is primarily JavaScript.
D is correct.
B is likely correct (Verify based on the Node.js version).
B is correct.
D is correct.
C is the most appropriate answer in a DOM context.
B is correct. GruntJS is a task runner.
C is correct. Node.js is single-threaded and not ideal for heavy CPU loads.
C is the most common and recommended style.
True/False Questions
- The `Buffer` class is global and doesn't require importing.
- Node.js is multithreaded.
- The `process` object is global.
- Node.js uses a blocking I/O model.
net.isIP(input)
returns 0 for invalid input.- A stream emits a `finish` event when all data is written.
- A stream emits a `data` event when data is available.
True
False
True
False. It uses a non-blocking, event-driven model.
True
True
True
Conclusion
This quiz tested your knowledge of various Node.js concepts. Regular practice of these types of questions will help you solidify your understanding and prepare for technical interviews.