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 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 - By default, npm installs any dependency in the local mode.

A - true

B - false

Answer : A

Explanation

By default, npm installs any dependency in the local mode.

Q 3 - Which of the following provides in-built events.

A - events

B - callback

C - throw

D - handler

Answer : A

Explanation

Node has multiple in-built events available through events module.

Answer : A

Explanation

fs.close(fd, callback) is the method which is used to close 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).

Answer : B

Explanation

os.endianness() returns the endianness of the CPU. Possible values are "BE" or "LE".

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.

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 : A

Explanation

http.request(options, callback) method can be used to make a request a web server.

Q 10 - A stream fires finish event when all data has been flushed to underlying system.

A - true

B - false

Answer : A

Explanation

A stream fires finish event when all data has been flushed to underlying system.


nodejs_questions_answers.htm

Advertisements