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.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. 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) APIs are modular
View Answer
Explanation: For handling the spontaneous events occurring on the web page the event handlers are important. 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. The command can be written more simply like node program.
4. What is the alternative command used in Node for load()?
a) store()
b) module()
c) log()
d) require()
View Answer
Explanation: require() is used for including other javascript files. 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: Console.log() prints the content in the argument on to the output screen. 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”); });
View Answer
Explanation: SetTimeout function is used to hold the execution of the code with the required amount of time. The argument of the setTimeout includes the function which is to be executed followed by the time after which the code is to be executed.
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: Client-side timer functions are used to perform applications based on time constraints. 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: The process object is a global that provides information about, and control over, the current Node.js process. 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) Recursive
View Answer
Explanation: Node executes the function the in one go without any waiting or blocking. Because the 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: The on() method attaches one or more event handlers for the selected elements and child elements. Node objects that generate events (known as event emitters) define an on() method for registering handlers.
Sanfoundry Global Education & Learning Series – Javascript Programming.
- Practice Programming MCQs
- Check JavaScript Books
- Apply for Computer Science Internship
- Practice Information Science MCQs
- Check Programming Books