Node Js MCQ Questions And Answers
NodeJs MCQ : This section focuses on "Basics" of Node Js. These Multiple Choice Questions (MCQ) should be practiced to improve the NodeJs skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Which of the following is true about Node.js?
A. Node.js is an open source server environment.
B. Node.js allows you to run JavaScript on the server.
C. Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
D. All of the above
View Answer
Ans : D
Explanation: All of the above statement are true.
2. Node.js uses _____________ programming.
A. asynchronous
B. synchronous
C. Both A and B
D. None of the above
View Answer
Ans : A
Explanation: Node.js uses asynchronous programming.
3. Which of the following is false?
A. Node.js can create, open, read, write, delete, and close files on the server
B. Node.js can generate static page content
C. Node.js can collect form data
D. Node.js can add, delete, modify data in your database
View Answer
Ans : B
Explanation: False, Node.js can generate dynamic page content.
4. Node.js files have extension?
A. .njs
B. .node
C. .js
D. .nj
View Answer
Ans : C
Explanation: Node.js files have extension .js
5. Node.js files must be initiated in the?
A. Command Prompt
B. nodejs Editor
C. Both A and B
D. None of the above
View Answer
Ans : A
Explanation: Node.js files must be initiated in the "Command Line Interface" program of your computer.
6. Node.js runs?
A. single-threaded
B. non-blocking
C. asynchronously programming
D. All of the above
View Answer
Ans : D
Explanation: Node.js runs single-threaded, non-blocking, asynchronously programming, which is very memory efficient.
7. Syntax to Initiate the Node.js File is?
A. filename.js
B. javascript filename.js
C. node filename.js
D. node filename
View Answer
Ans : C
Explanation: Syntax to Initiate the Node.js File is node filename.js.
8. To include a module, use the ___________ function with the name of the module.
A. function()
B. require()
C. exports()
D. module()
View Answer
Ans : B
Explanation: To include a module, use the require() function with the name of the module : var http = require('http');
9. Which keyword is used to make properties and methods available outside the module file?
A. import
B. module
C. exports
D. require
View Answer
Ans : C
Explanation: Use the exports keyword to make properties and methods available outside the module file.
10. Node.js has a built-in module called?
A. https
B. http
C. server
D. module
View Answer
Ans : B
Explanation: Node.js has a built-in module called HTTP, which allows Node.js to transfer data over the Hyper Text Transfer Protocol (HTTP).
11. Which method appends specified content to a file.
A. fs.appendFile()
B. fs.open()
C. fs.writeFile()
D. None of the above
View Answer
Ans : A
Explanation: The fs.appendFile() method appends specified content to a file. If the file does not exist, the file will be created.
12. Which method to create an HTTP server?
A. createServer()
B. getServer()
C. putServer()
D. setServer()
View Answer
Ans : A
Explanation: Use the createServer() method to create an HTTP server
13. Which of the following command will show version of Node?
A. $ npm --version
B. $ npm getVersion
C. $ node getVersion
D. $ node --version
View Answer
Ans : D
Explanation: Executing $ node --version command will show the version of Node instance.
14. The Node.js modules can be exposed using
A. module.expose
B. module
C. module.exports
D. All of the above
View Answer
Ans : C
Explanation: The Node.js modules can be exposed using module.exports.
15. What are the key features of Node.js?
A. Real time Data intensive
B. Highly scalable servers for Web Applications
C. Builds fast and scalable network Applications
D. All of the above
View Answer
Ans : D
Explanation: All of the above statement are correct.
16. Which of the following is true about process global object?
A. The process object is an instance of EventEmitter.
B. process emits exit event when process is about to exit.
C. process emits uncaughtException when when an exception bubbles all the way back to the event loop.
D. All of the above
View Answer
Ans : D
Explanation: The process object is an instance of EventEmitter and emits the above mentioned events.
17. which of the following areas, Node.js is not advised to be used?
A. Single Page Applications
B. JSON APIs based Applications
C. CPU intensive applications
D. Data Intensive Realtime Applications (DIRT)
View Answer
Ans : C
Explanation: It is not advisable to use Node.js for CPU intensive applications.
18. A package in Node.js contains all the files you need for a module.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, A package in Node.js contains all the files you need for a module.
19. The URL module splits up a web address into readable parts.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: The URL module splits up a web address into readable parts. To include the URL module, use the require() method
20. The fs.read() method is used to read files on your computer.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : B
Explanation: The fs.readFile() method is used to read files on your computer.
Discussion