Node.js Quiz ( Beginner ) - All Questions
This easy-level Node.js quiz is perfect for beginners who want to test their understanding of core Node.js fundamentals. It focuses on basic concepts like runtime, modules, event loop, npm, and simple server-side logic to build a strong foundation.
Question 1: What is Node.js?
- A JavaScript framework
- A JavaScript runtime environment
- A database
- A programming language
Explanation: Node.js is a runtime environment that allows JavaScript to run outside the browser.
Question 2: Node.js is built on which JavaScript engine?
- SpiderMonkey
- Chakra
- V8
- JavaScriptCore
Explanation: Node.js uses Google's V8 JavaScript engine.
Question 3: Which company developed Node.js?
- Google
- Microsoft
- Facebook
- Joyent
Explanation: Node.js was originally developed by Joyent.
Question 4: Which command is used to check the Node.js version?
- node --version
- node -v
- npm version
- check node
Explanation: node -v displays the installed Node.js version.
Question 5: What does npm stand for?
- Node Package Manager
- New Project Manager
- Node Program Module
- Network Package Manager
Explanation: npm stands for Node Package Manager.
Question 6: Which file stores project metadata in Node.js?
- node.json
- config.json
- package.json
- project.json
Explanation: package.json stores project details and dependencies.
Question 7: Which module system is used by default in Node.js?
Explanation: Node.js uses the CommonJS module system by default.
Question 8: Which keyword is used to import a module in CommonJS?
Explanation: require is used to import CommonJS modules.
Question 9: Which keyword is used to export a module in CommonJS?
- export
- exports
- module.exports
- default
Explanation: module.exports is used to export modules in CommonJS.
Question 10: Node.js is best suited for which type of applications?
- CPU-intensive applications
- I/O-intensive applications
- Desktop applications
- Embedded systems
Explanation: Node.js excels at handling I/O-intensive tasks.
Question 11: Which built-in module is used to create a web server?
Explanation: The http module is used to create servers.
Question 12: Which method starts an HTTP server?
- server.run()
- server.start()
- server.listen()
- server.open()
Explanation: server.listen() starts the server.
Question 13: Which Node.js module is used to work with files?
Explanation: The fs module is used for file system operations.
Question 14: What does non-blocking I/O mean?
- Tasks block the main thread
- Tasks execute one by one
- Tasks execute asynchronously
- Tasks execute slower
Explanation: Non-blocking I/O allows tasks to run asynchronously.
Question 15: Which core concept allows Node.js to handle multiple requests efficiently?
- Multi-threading
- Event loop
- Forking
- Polling
Explanation: The event loop enables asynchronous request handling.
Question 16: Which object represents the current module?
Explanation: The module object represents the current module.
Question 17: Which global object is available everywhere in Node.js?
- window
- document
- global
- browser
Explanation: global is the global object in Node.js.
Question 18: Which function is used to read command-line arguments?
- process.argv
- process.env
- console.args
- node.args
Explanation: process.argv contains command-line arguments.
Question 19: Which module provides information about the operating system?
Explanation: The os module provides OS-related information.
Question 20: Which Node.js module helps in handling file paths?
Explanation: The path module helps manage file paths.
Question 21: Which HTTP method is commonly used to fetch data?
Explanation: GET is used to retrieve data.
Question 22: What does the fs.readFile method do?
- Writes to a file
- Deletes a file
- Reads file content asynchronously
- Renames a file
Explanation: fs.readFile reads file content asynchronously.
Question 23: Which keyword stops Node.js execution?
- stop()
- exit()
- process.exit()
- terminate()
Explanation: process.exit() terminates the Node.js process.
Question 24: What type of language is JavaScript in Node.js?
- Compiled
- Interpreted
- Assembly
- Low-level
Explanation: JavaScript is an interpreted language.
Question 25: Which file extension is commonly used for Node.js files?
Explanation: .js is the standard file extension.
Question 26: Which npm command installs dependencies?
- npm start
- npm init
- npm install
- npm run
Explanation: npm install installs project dependencies.
Question 27: What does npm init do?
- Starts the server
- Creates package.json
- Installs Node.js
- Runs tests
Explanation: npm init creates a package.json file.
Question 28: Which keyword handles errors in async callbacks?
Explanation: catch is used to handle errors in promises.
Question 29: Which method sends a response to the client?
- res.send()
- req.send()
- req.write()
- res.read()
Explanation: res.send() sends a response.
Question 30: What is the default package manager for Node.js?
Explanation: npm is bundled with Node.js.
Question 31: Which Node.js feature supports asynchronous code?
- Callbacks
- Promises
- Async/Await
- All of the above
Explanation: Node.js supports callbacks, promises, and async/await.
Question 32: Which module helps convert callback-based APIs to promises?
Explanation: util.promisify converts callbacks to promises.
Question 33: What does event-driven architecture mean?
- Code runs sequentially
- Code reacts to events
- Code runs in threads
- Code blocks execution
Explanation: Node.js responds to events asynchronously.
Question 34: Which object emits events in Node.js?
- Emitter
- EventEmitter
- Dispatcher
- Listener
Explanation: EventEmitter is used to emit and listen to events.
Question 35: Which Node.js module handles events?
Explanation: The events module provides event handling.
Question 36: What is a callback function?
- A function called immediately
- A function passed as an argument
- A function that returns data
- A function that blocks code
Explanation: Callbacks are functions passed to other functions.
Question 37: Which method writes data to a file?
- fs.readFile
- fs.appendFile
- fs.writeFile
- fs.open
Explanation: fs.writeFile writes data to a file.
Question 38: Which module provides cryptographic functionality?
Explanation: The crypto module provides cryptographic features.
Question 39: What does process.env store?
- Command-line arguments
- Environment variables
- Node.js version
- Project dependencies
Explanation: process.env contains environment variables.
Question 40: Which object represents the incoming request?
Explanation: req represents the client request.
Question 41: Which object represents the server response?
Explanation: res is used to send responses.
Question 42: Which function schedules code execution after a delay?
- setInterval
- setImmediate
- setTimeout
- delay
Explanation: setTimeout executes code after a delay.
Question 43: Which function repeats execution at intervals?
- setTimeout
- setInterval
- repeat()
- loop()
Explanation: setInterval runs code repeatedly at intervals.
Question 44: Which Node.js module is used for streams?
Explanation: The stream module handles streaming data.
Question 45: What does buffer represent in Node.js?
- Text data
- Binary data
- JSON data
- HTML data
Explanation: Buffers handle raw binary data.
Question 46: Which command removes a dependency?
- npm delete
- npm uninstall
- npm remove
- npm clean
Explanation: npm uninstall removes a dependency.
Question 47: What is the main use of Node.js?
- Frontend development
- Server-side development
- Game engines
- Mobile UI
Explanation: Node.js is primarily used for backend development.