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

Answer : B

Explanation

REPL stands for Read Eval Print Loop and it represents a computer environment like a window console or Unix/Linux shell where a command is entered and system responds with an output in interactive mode.

Q 2 - Which of the following command will show version of npm?

A - $ npm --version

B - $ node --version

C - $ npm getVersion

D - $ node getVersion

Answer : A

Explanation

Executing $ npm --version command will show the version of npm instance.

Q 3 - Which of the following code gets length of a buffer buf?

A - buf.length

B - buf.size

C - buf.length()

D - buf.size()

Answer : A

Explanation

buf.length returns size of a node buffer in bytes.

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 setInterval(cb, ms) global function is used to run callback cb repeatedly 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 using the function clearInterval(t).

Answer : B

Explanation

os.type() returns the operating system name.

Answer : B

Explanation

os.platform() returns the operating system platform.

Answer : A

Explanation

net.connect(options[, connectionListener]) is a factory method, which returns a new 'net.Socket' and connects to the supplied address and port and can be used to create a client.

Answer : C

Explanation

The fork() method method is a special case of the spawn() to create Node processes. It returns object with a built-in communication channel in addition to having all the methods in a normal ChildProcess instance.

Q 10 - A stream fires error event when there is any error receiving or writing data.

A - false

B - true

Answer : B

Explanation

A stream fires error event when there is any error receiving or writing data.

nodejs_questions_answers.htm
Advertisements