- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
Node.js Mock Test
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.
Node.js Mock Test III
Answer : A
Explanation
Node.js console is a global object and is used to print different levels of messages to stdout and stderr.
Q 2 - Which of the following is true about console global object?
B - console is used in synchronous way when destination is file or a terminal.
C - console is used in asynchronous way when destination is a pipe.
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
The process object is a global object and can be accessed from anywhere.
Q 4 - Which of the following is true about process global object?
A - The process object is an instance of EventEmitter.
Answer : D
Explanation
The process object is an instance of EventEmitter and emits the above mentioned events.
Q 5 - Which of the following code prints current directory?
A - console.log('Current directory: ' + process.cwd());
B - console.log('Current directory: ' + console.cwd());
C - console.log('Current directory: ' + process.currenWorkingDirectory());
Answer : A
Explanation
process.cwd() can be used to get the current working directory.
Q 6 - Which of the following code prints process version?
A - console.log('Current version: ' + process.version());
B - console.log('Current version: ' + process.version);
C - console.log('Current version: ' + process.getVersion());
Answer : B
Explanation
process.version can be used to get the current process version.
Q 7 - Which of the following code prints memory usage?
A - console.log(process.memoryUsage());
B - console.log('Current version: ' + process.memory());
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?
Answer : A
Explanation
Node.js os module provides a few basic operating-system related utility functions.
Q 9 - Which of the following code print the endianness of operating system?
A - console.log('endianness : ' + os.endianness);
B - console.log('endianness : ' + os.endianness());
Answer : B
Explanation
os.endianness() returns the endianness of the CPU. Possible values are "BE" or "LE".
Q 10 - Which of the following code print the name of operating system?
A - console.log('type : ' + os.type);
B - console.log('type : ' + os.type());
Answer : B
Explanation
os.type() returns the operating system name.
Q 11 - Which of the following code print the platform of operating system?
A - console.log('platform : ' + os.platform);
B - console.log('platform : ' + os.platform());
Answer : B
Explanation
os.platform() returns the operating system platform.
Q 12 - Which of the following code print the total system memory of operating system?
A - console.log('total memory : ' + os.totalmem() + " bytes.");
B - console.log('total memory : ' + os.totalmem + " bytes.");
C - console.log('total memory : ' + os.getTotalMemory() + " bytes.");
Answer : A
Explanation
os.totalmem() returns the total amount of system memory in bytes.
Q 13 - Which of the following code print the total free memory of operating system?
A - console.log('free memory : ' + os.freemem() + " bytes.");
B - console.log('free memory : ' + os.freemem + " bytes.");
C - console.log('free memory : ' + os.getFreeMemory() + " 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?
Answer : C
Explanation
Node.js path module is used for handling and transforming file paths.
Q 15 - Which of the following is the correct way to get a normalized path?
A - path.normalize('/test/test1//2slashes/1slash/tab/..')
B - fs.normalize('/test/test1//2slashes/1slash/tab/..')
Answer : A
Explanation
path.normalize(p) normalizes a string path, taking care of '..' and '.' parts.
Q 16 - Which of the following is the correct way to get a joint path?
A - path.join('/test', 'test1', '2slashes/1slash', 'tab', '..')
B - path.combine('/test', 'test1', '2slashes/1slash', 'tab', '..')
C - buffer.join('/test', 'test1', '2slashes/1slash', 'tab', '..')
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?
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?
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?
Answer : C
Explanation
Node.js net module is used to create both servers and clients. This module provides an aynchronous network wrapper.
Q 20 - Which of the following API creates a server?
A - net.createServer([options][, connectionListener])
B - net.connect(options[, connectionListener])
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 21 - Which of the following API creates a client?
A - net.createServer([options][, connectionListener])
B - net.connect(options[, connectionListener])
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.
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
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
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
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 |