JavaScript Questions & Answers – Asynchronous I/O with Rhino

«
»

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

Answer: a
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.
advertisement

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

Answer: b
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

Answer: c
Explanation: The node programs can be run with the command:node program.js. The command can be written more simply like node program.
advertisement
advertisement

4. What is the alternative command used in Node for load()?
a) store()
b) module()
c) log()
d) require()
View Answer

Answer: d
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

Answer: b
Explanation: Console.log() prints the content in the argument on to the output screen. Node defines console.log() for debugging output like browsers do.
advertisement

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

Answer: a
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

Answer: d
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().
advertisement

8. The necessary globals of a node are defined under which namespace?
a) variables
b) system
c) process
d) using
View Answer

Answer: c
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

Answer: b
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.
advertisement

10. Which is the method used for registering handlers?
a) on()
b) register()
c) add()
d) include()
View Answer

Answer: a
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.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter