Node.js Mock Test


Advertisements

This section presents you various set of Mock Tests related to Node.js Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Node.js Mock Test IV

Q 1 - Which of the following module is required for DNS specific operations?

A - dns module

B - web module

C - net module

D - None of the above.

Answer : A

Explanation

Node.js dns module is used to do actual DNS lookup as well as to use underlying operating system name resolution functionalities.

Answer : C

Explanation

dns.lookup(hostname[, options], callback) resolves a hostname (e.g. 'google.com') into the first found A (IPv4) or AAAA (IPv6) record. options can be an object or integer. If options is not provided, then IP v4 and v6 addresses are both valid. If options is an integer, then it must be 4 or 6.

Q 3 - 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 4 - Which of the following module is required for exception handling in Node?

A - web module

B - net module

C - domain module

D - error module

Answer : C

Explanation

Node.js domain module is used to intercept unhandled error. These unhandled error can be intercepted using internal binding or external binding. If errors are not handled at all then they will simply crash the Node application.

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 7 - Which of the following module is required to create a web server?

A - url module

B - net module

C - http module

D - web module

Answer : C

Explanation

Node.js provides http module which can be used to create HTTP client of server.

Answer : A

Explanation

http.createServer(callback) method can be used to create a web server.

Answer : A

Explanation

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

Answer : B

Explanation

Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications.

Q 11 - Can we create child processes in Node applications.

A - true

B - false

Answer : A

Explanation

Node facilitates creation of child processes to leverage parallel processing on multi-core cpu based systems.

Q 12 - 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.

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.

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.

Answer : A

Explanation

REST stands for REpresentational State Transfer.

Answer : C

Explanation

Webservices based on REST Architecture are known as RESTful web services. These webservices uses HTTP methods to implement the concept of REST architecture.

Q 17 - 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.

Q 18 - 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.

Q 19 - Each type of Stream is an EventEmitter.

A - true

B - false

Answer : A

Explanation

Each type of Stream is an EventEmitter instance and throws several events at different instance of times.

Q 20 - Duplex stream can be used for both read and write operation.

A - true

B - false

Answer : A

Explanation

Duplex stream can be used for both read and write operation.

Q 21 - 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.

Q 22 - A stream fires end event when there is no more data to read.

A - true

B - false

Answer : A

Explanation

A stream fires end event when there is no more data to read.

Q 23 - 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.

Q 24 - 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.

Q 25 - Child processes always have three streams child.stdin, child.stdout, and child.stderr which may be shared with the stdio streams of the parent process.

A - true

B - false

Answer : A

Explanation

Child processes always have three streams child.stdin, child.stdout, and child.stderr which may be shared with the stdio streams of the parent process.

Answer Sheet

Question Number Answer Key
1 A
2 C
3 A
4 C
5 A
6 B
7 C
8 A
9 A
10 B
11 A
12 B
13 D
14 C
15 A
16 C
17 D
18 A
19 A
20 A
21 B
22 A
23 B
24 A
25 A
nodejs_questions_answers.htm
Advertisements