Node.js Online Quiz


Advertisements


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

Answer : C

Explanation

Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.

Q 2 - Which of the following command will show all the modules installed globally?

A - $ npm ls -g

B - $ npm ls

C - $ node ls -g

D - $ node ls

Answer : A

Explanation

Executing $ npm ls -g command will show all the modules installed globally.

Answer : C

Explanation

Readable stream is used for read operation and its output can be input to a writable stream.

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

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

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

C - package fs;

D - import fs;

Answer : A

Explanation

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

Answer : C

Explanation

The setTimeout(cb, ms) global function is used to run callback cb after at least ms milliseconds. The actual delay depends on external factors like OS timer granularity and system load. A timer cannot span more than 24.8 days. This function returns an opaque value that represents the timer which can be used to clear the timer.

Answer : D

Explanation

Node.js console is a global object and is used to print different levels of messages to stdout and stderr. There are built-in methods to be used for printing informational, warning and error messages. It is used in synchronous way when destination is file or a terminal and asynchronous way when destination is a pipe.

Q 7 - Which of the following is the correct way to get an extension of a file?

A - fs.extname('main.js')

B - path.extname('main.js')

C - os.extname('main.js')

D - None of the above.

Answer : B

Explanation

path.extname(p) returns the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.

Answer : A

Explanation

Error emmitter is executing its code within run method of a domain in case of internal binding.

Answer : B

Explanation

Error emmitter is added explicitly to a domain using its add method in case of external binding.

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