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.
Q 1Which of following command starts a REPL session?
REPL can be started by simply running node on shell/console without any argument.
Q 2 - Which of the following command will show all the modules installed globally?
Executing $ npm ls -g command will show all the modules installed globally.
Q 3 - Which of the following code gets length of a buffer buf?
buf.length returns size of a node buffer in bytes.
Q 4 - Which method of fs module is used to read a file?
A - fs.open(path, flags[, mode], callback)
B - fs.openFile(path, flags[, mode], callback)
fs.read(fd, buffer, offset, length, position, callback) is the method which is used to read a file.
Q 5 - Which of the following is true about setInterval(cb, ms) global function?
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).
Node.js console is a global object and is used to print different levels of messages to stdout and stderr.
Q 7 - 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', '..')
path.join([path1][, path2][, ...]) joins all arguments together and normalize the resulting path.
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 9 - Which of the following is true about exec methd of child_process module.
A - The exec() method runs a command in a shell and buffers the output.
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.
Transform stream is a duplex stream where the output is computed based on input.