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.
Show Answer
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
Show Answer
A is correct. REPL stands for Read-Eval-Print Loop.
- Which command starts a REPL session?
node
node start
node repl
node console
Show Answer
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
Show Answer
E is correct. Node.js uses a combination of languages.
Show Answer
A is correct.
Show Answer
B is correct. A callback is primarily used for asynchronous operations.
Show Answer
A is correct.
Show Answer
C is correct. Use module.exports
.
Show Answer
D is correct.
Show Answer
B is correct. fs.stat()
provides file statistics.
Show Answer
B is correct. `fs` stands for File System.
Show Answer
C is correct.
Show Answer
D is correct. Many templating engines work with Node.js.
Show Answer
B is correct. Use os.platform()
.
Show Answer
A is correct. Use process.cwd()
.
Show Answer
B is correct.
Show Answer
C is correct. Modules don't directly reduce program size.
Show Answer
While all are good practices, A (gzip compression) directly impacts performance.
Show Answer
B is correct. Variables are typically locally scoped unless declared globally.
Show Answer
A is correct.
Show Answer
B is correct.
Show Answer
B is correct. Node.js primarily uses JavaScript.
Show Answer
D is correct.
Show Answer
B is correct (This might need verification based on the specific Node.js version).
Show Answer
B is correct.
Show Answer
D is correct.
Show Answer
C is correct (This depends on the context; `isEqualNode()` is common in DOM APIs).
Show Answer
B is correct. GruntJS is a popular task runner.
Show Answer
C is correct. Node.js is not ideal for CPU-bound tasks.
Show Answer
While all *could* work depending on the implementation, C is the most standard and recommended format.
Conclusion
This MCQ section tested your knowledge of various Node.js concepts. Regularly reviewing these types of questions will help solidify your understanding.