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

Q 1Which of following command starts a REPL session?

A - $ node

B - $ node start

C - $ node repl

D - $ node console

Answer : A

Explanation

REPL can be started by simply running node on shell/console without any argument.

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.

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.

Answer : D

Explanation

fs.read(fd, buffer, offset, length, position, callback) is the method which is used to read a file.

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).

Q 6 - Is console a global object?

A - true

B - false

Answer : A

Explanation

Node.js console is a global object and is used to print different levels of messages to stdout and stderr.

Answer : A

Explanation

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

Q 8 - net.isIP(input) returns 4 for IP version 4 addresses.

A - true

B - false

Answer : A

Explanation

net.isIP(input) tests if input is an IP address. Returns 0 for invalid strings, returns 4 for IP version 4 addresses, and returns 6 for IP version 6 addresses.

Answer : D

Explanation

child_process.exec method runs a command in a shell and buffers the output. It returns a buffer with a max size and waits for the process to end and tries to return all the buffered data at once.

Q 10 - Transform stream is a type of duplex stream.

A - true

B - false

Answer : A

Explanation

Transform stream is a duplex stream where the output is computed based on input.

nodejs_questions_answers.htm
Advertisements