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.

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

Explanation

fs.writeFile(path, flags[, mode], callback) is the method which is used to write a file.

Answer : C

Explanation

Node.js global objects are global in nature and they are available in all modules. We do not need to include these objects in our application, rather we can use them directly.

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.

Answer : A

Explanation

net.createServer([options][, connectionListener]) creates a new TCP server. The connectionListener argument is automatically set as a listener for the 'connection' event.

Q 8 - Which of the following method resolves an ip address to an array of hostnames?

A - dns.reverse(ip, callback)

B - dns.resolve(hostname[, rrtype], callback)

C - dns.resolve4(hostname, callback)

D - None of the above.

Answer : A

Explanation

dns.reverse(ip, callback) resolves an ip address to an array of hostnames.

Q 9 - Which of the following module is required to create a child process?

A - process module

B - child_process module

C - child module

D - web module

Answer : B

Explanation

Node provides child_process module which provides ways to create child process.

Q 10 - Which of the following is not a valid HTTP method?

A - get

B - put

C - post

D - header

Answer : D

Explanation

header is not a valid HTTP method.


nodejs_questions_answers.htm

Advertisements