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 III

Q 1 - 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 : 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.

Q 3 - Is process a global object?

A - true

B - false

Answer : A

Explanation

The process object is a global object and can be accessed from anywhere.

Answer : D

Explanation

The process object is an instance of EventEmitter and emits the above mentioned events.

Answer : A

Explanation

process.cwd() can be used to get the current working directory.

Answer : B

Explanation

process.version can be used to get the current process version.

Answer : A

Explanation

process.memoryUsage() can be used to get the memory usage.

Q 8 - Which of the following module is required for operating system specific operations?

A - os module

B - fs module

C - net module

D - None of the above.

Answer : A

Explanation

Node.js os module provides a few basic operating-system related utility functions.

Answer : B

Explanation

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

Answer : B

Explanation

os.type() returns the operating system name.

Answer : B

Explanation

os.platform() returns the operating system platform.

Answer : A

Explanation

os.totalmem() returns the total amount of system memory in bytes.

Answer : A

Explanation

os.freemem() returns the free amount of system memory in bytes.

Q 14 - Which of the following module is required for path specific operations?

A - os module

B - fs module

C - path module

D - None of the above.

Answer : C

Explanation

Node.js path module is used for handling and transforming file paths.

Answer : A

Explanation

path.normalize(p) normalizes a string path, taking care of '..' and '.' parts.

Answer : A

Explanation

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

Q 17 - Which of the following is the correct way to get an absolute path?

A - os.resolve('main.js')

B - path.resolve('main.js')

C - fs.resolve('main.js')

D - None of the above.

Answer : B

Explanation

path.resolve([from ...], to) resolves to an absolute path.

Q 18 - 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 19 - Which of the following module is required for network specific operations?

A - os module

B - fs module

C - net module

D - None of the above.

Answer : C

Explanation

Node.js net module is used to create both servers and clients. This module provides an aynchronous network wrapper.

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.

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.

Q 22 - net.isIP(input) tests if input is an IP address or not.

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.

Q 23 - net.isIP(input) returns 0 for invalid input.

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.

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

Q 25 - net.isIP(input) returns 6 for IP version 6 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 Sheet

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