• Node.js Video Tutorials

Node.js Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to Node.js Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following statement is valid to use a Node module http in a Node based application?

A - var http = require("http");

B - var http = import("http");

C - package http;

D - import http;

Answer : A

Explanation

Require directive is used to load a Node module(http) and store returned its instance(http) into its variable(http).

Q 2 - Which of the following command will show all the modules installed locally.

A - $ npm ls -g

B - $ npm ls

C - $ node ls -g

D - $ node ls

Answer : B

Explanation

Executing $ npm ls command will show all the modules installed locally.

Answer : D

Explanation

Node js is a single threaded application but it support concurrency via concept of event and callbacks. As every API of Node js are asynchronous and being a single thread, it uses async function calls to maintain the concurrency. Node uses observer pattern. Node thread keeps an event loop and whenever any task get completed, it fires the corresponding event which signals the event listener function to get executed.

Answer : A

Explanation

fs.close(fd, callback) is the method which is used to close a file.

Answer : C

Explanation

fs.readdir(path, callback)is the method which is used to read a directory.

Answer : D

Explanation

The process object is an instance of EventEmitter and emits the above mentioned events.

Answer : A

Explanation

path.join([path1][, path2][, ...]) joins all arguments together and normalize the resulting path.

Q 8 - Which of the following module is required for exception handling in Node?

A - web module

B - net module

C - domain module

D - error module

Answer : C

Explanation

Node.js domain module is used to intercept unhandled error. These unhandled error can be intercepted using internal binding or external binding. If errors are not handled at all then they will simply crash the Node application.

Q 9 - Can we create child processes in Node applications.

A - true

B - false

Answer : A

Explanation

Node facilitates creation of child processes to leverage parallel processing on multi-core cpu based systems.

Q 10 - A stream fires data event when there is data available to read.

A - false

B - true

Answer : B

Explanation

A stream fires data event when there is data available to read.

nodejs_questions_answers.htm
Advertisements