This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Asynchronous I/O with Rhino”.
1. Which is a fast C++ based JavaScript interpreter?
a) Node
b) Sockets
c) Processors
d) Closures
View Answer
Explanation: Node is a fast C++-based JavaScript interpreter with bindings to the low-level Unix APIs for working with processes, files, network sockets, etc., and also to HTTP client and server APIs.
2. Why does the Node rely on event handlers?
a) APIs are synchronous
b) APIs are asynchronous
c) APIs are reusable
d) None of the mentioned
View Answer
Explanation: Because the APIs are asynchronous, Node relies on event handlers, which are often implemented using nested functions and closures.
3. What is the command to run the node programs?
a) node(program.js)
b) program.js
c) node program.js
d) node.program.js
View Answer
Explanation: The node programs can be run with the command:
node program.js
4. What is the alternative command used in Node for load()?
a) store()
b) module()
c) log()
d) require()
View Answer
Explanation: Use require() instead of load(). It loads and executes (only once) the named module, returning an object that contains its exported symbols.
5. What is the command used for debugging output in Node?
a) print();
b) console.log(…);
c) debug(…);
d) execute(…);
View Answer
Explanation: Node defines console.log() for debugging output like browsers do.
6. What is the code to print hello one second from now?
a) setTimeout(function() { console.log("Hello World"); }, 1000); b) setTimeout(function() { 1000, console.log("Hello World"); }); c) setTimeout(function(1000) { console.log("Hello World"); }); d) setTimeout(function() { console.log("Hello World"); });
Explanation: The above code snippet says hello one second from now.
7. Among the below given functions, Node supports which of the following client-side timer functions?
a) getInterval()
b) Interval()
c) clearTime()
d) clearTimeout()
View Answer
Explanation: Node supports the client-side timer functions set setTimeout(), setInterval(), clearTimeout(), and clearInterval().
8. The necessary globals of a node are defined under which namespace?
a) variables
b) system
c) process
d) using
View Answer
Explanation: Node defines other important globals under the process namespace.
9. Why does Node not block while waiting for operations to complete?
a) Static
b) Asynchronous
c) Synchronous
d) None of the mentioned
View Answer
Explanation: Because Node’s functions and methods are asynchronous, they do not block while waiting for operations to complete.
10. Which is the method used for registering handlers?
a) on()
b) register()
c) add()
d) include()
View Answer
Explanation: Node objects that generate events (known as event emitters) define an on() method for registering handlers.
Sanfoundry Global Education & Learning Series – Javascript Programming.