Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

What is the alternative command used in Node for load()?(a) store()(b) module()(c) log()(d) require()I have been asked this question during an interview.I'd like to ask this question from Asynchronous I/O with Rhino topic in division Server-Side and Client-Side Scripting of JavaScript

Answer»

Right choice is (d) require()

To elaborate: 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.

52.

What is the command to run the node programs?(a) node(program.js)(b) program.js(c) node program.js(d) node.program.jsThis question was posed to me during a job interview.This question is from Asynchronous I/O with Rhino topic in section Server-Side and Client-Side Scripting of JavaScript

Answer»

Correct answer is (c) NODE PROGRAM.js

For EXPLANATION I would say: The node programs can be run with the COMMAND:node program.js. The command can be written more SIMPLY like node program.

53.

Why does the Node rely on event handlers?(a) APIs are synchronous(b) APIs are asynchronous(c) APIs are reusable(d) APIs are modularThis question was posed to me in an interview.The question is from Asynchronous I/O with Rhino in division Server-Side and Client-Side Scripting of JavaScript

Answer»

Correct answer is (b) APIs are asynchronous

The best I can EXPLAIN: 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.

54.

Which is a fast C++ based JavaScript interpreter?(a) Node(b) Sockets(c) Processors(d) ClosuresThe question was posed to me in an online quiz.Question is from Asynchronous I/O with Rhino topic in portion Server-Side and Client-Side Scripting of JavaScript

Answer» CORRECT choice is (a) Node

The best 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.
55.

The JavaScript classes can be instantiated using _____ operator.(a) create(b) new(c) instantiate(d) create.newThis question was posed to me in an internship interview.The doubt is from Scripting Java with Rhino topic in chapter Server-Side and Client-Side Scripting of JavaScript

Answer»

The correct answer is (B) new

For explanation I would say: New is a KEYWORD in JavaScript which is used to DEFINE new models. New operator is used to create new instance of the CLASS.

56.

What does Rhino do when the getter and setter methods exist?(a) It becomes JavaScript properties(b) Java classes are used to avoid them(c) Java classes & JavaScript properties(d) It act as javascript functionI have been asked this question in an interview for internship.The doubt is from Scripting Java with Rhino in portion Server-Side and Client-Side Scripting of JavaScript

Answer»

The correct OPTION is (a) It becomes JavaScript PROPERTIES

The best I can explain: Rhino ALLOWS JavaScript code to QUERY and set the static fields of Java classes and the instance fields of Java objects. Java classes often avoid defining public fields in favor of getter and setter methods. When getter and setter methods exist, Rhino EXPOSES them as JavaScript properties.

57.

Which is a more formal way of importing packages and classes as JavaScript objects?(a) import(java.util.*);(b) importClass(java.util.*);(c) import.Class(java.util.*);(d) Class.import(java.util.*);The question was asked in exam.This interesting question is from Scripting Java with Rhino topic in portion Server-Side and Client-Side Scripting of JavaScript

Answer»

Right option is (b) importClass(java.util.*);

Easy explanation: Because packages and CLASSES are represented as JavaScript objects, you can assign them to VARIABLES to GIVE them shorter names. But you can ALSO more FORMALLY import them, if you want to:

58.

Which is a useful way to try out small and simple Rhino programs and one-liners?(a) Starting an interactive shell(b) Starting a one to one shell(c) Creating a thread to do simple programs(d) Starting a multiple shellThe question was posed to me in an online quiz.My doubt stems from Scripting Java with Rhino topic in section Server-Side and Client-Side Scripting of JavaScript

Answer»

Right answer is (a) Starting an interactive shell

The explanation: Rhino is distributed as a JAR ARCHIVE. Start it with a command line like this :

java -jar rhino1_7R2/js.jar program.js

If you omit program.js, Rhino starts an interactive shell, which is USEFUL for TRYING out simple programs and one-liners.

59.

Which Rhino command quits Rhino environment?(a) terminate()(b) exit()(c) quit()(d) close()The question was asked in examination.This is a very interesting question from Scripting Java with Rhino in chapter Server-Side and Client-Side Scripting of JavaScript

Answer»

The CORRECT option is (c) quit()

For explanation I WOULD SAY: quit() is a predefined command in RHINO. The quit() command makes Rhino exit.

60.

What is the method used to pause “data” events?(a) s.pause();(b) s.stop();(c) s.halt();(d) s.wait();I had been asked this question in an interview.Question is from Server-Side JavaScript in division Server-Side and Client-Side Scripting of JavaScript

Answer»

Right CHOICE is (a) s.pause();

EXPLANATION: Data events are the events which are performed by either the USER or the BROWSER. The above CODE snippet is used to pause data events, for throttling uploads.

61.

Which of the following reads the textual contents of a URL and returns as a string?(a) spawn(f);(b) load(filename,…);(c) readFile(file);(d) readUrl(url);I got this question by my school teacher while I was bunking the class.My doubt stems from Scripting Java with Rhino in chapter Server-Side and Client-Side Scripting of JavaScript

Answer» CORRECT answer is (d) readUrl(url);

Best EXPLANATION: Rhino defines a HANDFUL of IMPORTANT global functions that are not PART of core JavaScript in which readUrl(url) reads the textual contents of a URL and return as a string.
62.

Which of the following are global functions that are not part of core JavaScript?(a) spawn(f);(b) trim();(c) exult();(d) eval()The question was asked during an interview.I'd like to ask this question from Scripting Java with Rhino topic in section Server-Side and Client-Side Scripting of JavaScript

Answer»

The CORRECT ANSWER is (a) SPAWN(f);

Easiest EXPLANATION: The spawn(f) runs f() or loads and executes file f in a new THREAD.

63.

When the “end” event fires on EOF when no more data will arrive, which function is called?(a) s.on(“data”,f);(b) s.on(“end”,f);(c) s.on(“error”,f);(d) s.on(“default”,f);I got this question by my college director while I was bunking the class.My question is based upon Server-Side JavaScript topic in section Server-Side and Client-Side Scripting of JavaScript

Answer»

Right ANSWER is (b) s.on(“end”,F);

For EXPLANATION: ”EOF” STANDS for end of file.The above code SNIPPET gets “end” event fired on EOF when no more data will arrive.

64.

Rhino is originated by _______(a) Microsoft(b) Mozilla(c) Apple(d) ChromeThis question was posed to me during an online interview.My question is based upon Scripting Java with Rhino topic in portion Server-Side and Client-Side Scripting of JavaScript

Answer»

The CORRECT option is (b) Mozilla

The explanation: Rhino is a JavaScript engine written FULLY in Java and managed by the Mozilla Foundation as open source software. Rhino is free software from Mozilla. You can download a copy from HTTP://www.mozilla.org/rhino/.

65.

Which among the following POSIX signals generate events?(a) SIGDOWN(b) SIGFLOAT(c) SIGINT(d) SIGSHORTI have been asked this question in final exam.This question is from Server-Side JavaScript topic in chapter Server-Side and Client-Side Scripting of JavaScript

Answer»

The correct option is (c) SIGINT

The explanation is: The SIGINT is a POSIX signal that GENERATES event. Simple code like below can do a proper clean up and exit on CTRL-C or SIGINT passed from command LINE / other application to the nodejs APP’s PROCESSID.

66.

Which of the following is an event emitter?(a) once(b) process(c) listeners(d) onI had been asked this question in an international level competition.Origin of the question is Server-Side JavaScript in section Server-Side and Client-Side Scripting of JavaScript

Answer»

Right answer is (b) process

To explain: The process object is an event emitter. The NODE defines other important globals under the process namespaces that contain properties of that object LIKE version, argv, env, PID, getuid(), cwd(), chdir() and EXIT().

67.

What is the function used to remove all handlers for name events?(a) deleteAllListeners(name)(b) deleteListener(name,f)(c) removeListener(name,f)(d) removeAllListeners(name)The question was asked in an interview for job.My question comes from Server-Side JavaScript topic in chapter Server-Side and Client-Side Scripting of JavaScript

Answer»

The correct answer is (d) removeAllListeners(NAME)

To explain I would SAY: The removeAllListeners(name) is USED to remove all handlers from name EVENTS REPRESENTED as :

emitter.removeAllListeners(name)

68.

Which function is a synonym for on()?(a) addListener()(b) listeners()(c) once()(d) add()I got this question in class test.I'm obligated to ask this question of Server-Side JavaScript topic in chapter Server-Side and Client-Side Scripting of JavaScript

Answer»

The correct choice is (a) addListener()

To elaborate: The on() METHOD is used for registering HANDLERS. addListener() is a SYNONYM for on().

69.

When do uncaught exceptions generate events?(a) When handlers are registered(b) When handlers are deregistered(c) When handler functions are called(d) When handlers do not have a matching catch clauseThis question was addressed to me in an international level competition.This interesting question is from Server-Side JavaScript in portion Server-Side and Client-Side Scripting of JavaScript

Answer»

Correct OPTION is (a) When HANDLERS are registered

For explanation I would SAY: The on() method and addListener() method PERFORM the same task of acting as an event emitter. The on() and addListener() method is used for registering handlers.

70.

What are the events generated by the Node objects called?(a) generators(b) emitters(c) dispatchers(d) higheventsI have been asked this question by my school teacher while I was bunking the class.Origin of the question is Server-Side JavaScript in division Server-Side and Client-Side Scripting of JavaScript

Answer»

Correct choice is (B) EMITTERS

Best explanation: There are two classes of events ONE is called event listener and the other is called event emitter. Node OBJECTS that generate events (KNOWN as event emitters) define an on() method for registering handlers.

71.

What is the function used to deregister event handler ‘f’?(a) deleteAllListeners(name)(b) deleteListener(name,f)(c) removeListener(name,f)(d) removeAllListeners(name)This question was addressed to me in an interview for internship.This is a very interesting question from Server-Side JavaScript topic in chapter Server-Side and Client-Side Scripting of JavaScript

Answer»

The correct answer is (C) removeListener(name,F)

BEST EXPLANATION: The removeEventListener() method removes an event handler that has been attached with the addEventListener() method. The removeListeners(name,f) is used to deregister event handler f REPRESENTED as :

emitter.removeListener(name,f)