Welcome to Node JS Quiz for beginners!. This quiz consists of 30 MCQs (Multiple-Choice Questions) to test your knowledge of Node JS concepts and NPM commands.
Node.js is a cross-platform environment and library for running JavaScript applications which is used to create networking and server-side applications.
Note that each question is followed by the correct answer and an explanation to help reinforce your knowledge.
1. What is Node.js?
A. A front-end framework
B. A back-end framework
C. A JavaScript runtime built on Chrome's V8 JavaScript engine
D. A type of database
2. Which package manager is bundled with Node.js by default?
A. npm
B. bower
C. yarn
D. grunt
3. How can you initiate a project using npm?
A. npm start
B. npm init
C. npm run
D. npm create
4. Which method is used in Node.js to include modules?
A. require()
B. include()
C. import
D. fetch()
5. Which core module in Node.js provides asynchronous file operations?
A. http
B. url
C. fs
D. path
6. In Node.js, which of the following is an in-built event emitter?
A. EventEmitter
B. Events
C. EventLoop
D. EventYield
7. Which global object provides functionality to control the Node.js runtime process?
A. Global
B. Runtime
C. Process
D. NodeControl
8. How can you read command-line arguments in a Node.js application?
A. argv
B. process.args
C. arguments
D. process.argv
9. Which method is used to create a new instance of a server in Node.js?
A. http.createServer()
B. http.createInstance()
C. http.newServer()
D. http.createServerInstance()
10. Which of the following is a core module for handling paths?
A. url
B. dir
C. path
D. location
11. What does the stream module in Node.js provide?
A. Tools for creating WebSockets
B. Utilities for handling HTTP operations
C. A way to handle streaming data
D. Functions for dealing with promises
12. What is the Node.js event loop?
A. A loop that emits custom events
B. A loop that continuously checks for events and processes them
C. A mechanism to define custom events
D. The main process of a Node.js application
13. Which utility allows you to automatically restart a Node application when changes are detected?
A. NodeLive
B. NodeReload
C. Nodemon
D. AutoNode
14. What is a buffer in Node.js?
A. A temporary storage spot for data being transferred
B. A type of variable
C. A mechanism to control data flow
D. A module for handling binary data
15. Which Node.js method is used to delay the execution of a function?
A. process.delay()
B. setTimeout()
C. wait()
D. sleep()
16. Which of the following allows Node.js to be scalable?
A. Multithreading
B. Event-driven architecture
C. Larger memory allocation
D. High CPU usage
17. What is the main difference between exports and module.exports in Node.js?
A. They are the same.
B. exports is for functions, while module.exports is for objects.
C. exports is a reference to module.exports.
D. module.exports is the legacy way to export modules.
18. What would be the primary use case for the cluster module in Node.js?
A. Data validation
B. Improved logging
C. Load balancing over multiple CPU cores
D. Data encryption
19. Which of the following is NOT a core module in Node.js?
A. fs
B. http
C. express
D. url
20. Which method in the fs module is used to read a file asynchronously?
A. fs.readFile()
B. fs.readSync()
C. fs.openFile()
D. fs.read()
21. In which object are all the environment variables stored in a Node.js application?
A. env
B. process.env
C. node.env
D. app.env
22. What does the eventEmitter.emit method in Node.js do?
A. It sets up a new event.
B. It triggers an event.
C. It listens for an event.
D. It terminates an ongoing event.
23. How do you install a package locally using npm in a Node.js application?
A. npm install -g <package-name>
B. npm local install <package-name>
C. npm run install <package-name>
D. npm install <package-name>
24. In a Node.js application, which method is used to send a JSON response back from a server?
A. res.json()
B. res.sendJSON()
C. res.returnJSON()
D. res.pushJSON()
25. What does the npm init command do?
A. It installs all the dependencies listed in package.json.
B. It starts the Node.js application.
C. It creates a new Node.js application.
D. It initializes a new package.json file.
26. Which of the following is used to import modules in Node.js?
A. import { module } from 'module-name'
B. #include 'module-name'
C. require('module-name')
D. using module-name
27. Which npm command is used to install all dependencies listed in the package.json file?
A. npm init
B. npm run
C. npm start
D. npm install
28. Which Node.js command is used to execute a JavaScript file, say "app.js"?
A. node install app.js
B. node run app.js
C. node app.js
D. npm app.js
29. What is the purpose of the --save flag in the npm install command?
A. To globally install a package
B. To save a backup of the current project
C. To save the package version in the package-lock.json
D. To save the package in the package.json dependencies
30. Which npm command can be used to list all globally installed packages?
A. npm list -g
B. npm global list
C. npm show
D. npm modules
Comments
Post a Comment
Leave Comment