261). What are the events generated by the Node objects called?
[A]generators
[B]emitters
[C]dispatchers
[D]highevents
Show Answer
Correct Answer: emitters
Notes:
Answer: b
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.
262). What is the function used to deregister event handler ‘f’?
[A]deleteAllListeners(name)
[B]deleteListener(name,f)
[C] removeListener(name,f)
[D]removeAllListeners(name)
Show Answer
Correct Answer: removeListener(name,f)
Notes:
Answer: c
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)
263). 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)
Show Answer
Correct Answer: removeAllListeners(name)
Notes:
Answer: d
Explanation: The removeAllListeners(name) is used to remove all handlers from name events represented as :
emitter.removeAllListeners(name)
264). Which function is a synonym for on()?
[A]addListener()
[B] listeners()
[C]once()
[D]add()
Show Answer
Correct Answer: addListener()
Notes:
Answer: a
Explanation: The on() method is used for registering handlers. addListener() is a synonym for on().
265). Which of the following is an event emitter?
[A]once
[B]process
[C]listeners
[D]on
Show Answer
Correct Answer: process
Notes:
Answer: b
Explanation: 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().
266). 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 clause
Show Answer
Correct Answer: When handlers are registered
Notes:
Answer: a
Explanation: 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.
267). Which among the following POSIX signals generate events?
[A]SIGDOWN
[B]SIGFLOAT
[C]SIGINT
[D]SIGSHORT
Show Answer
Correct Answer: SIGINT
Notes:
Answer: c
Explanation: 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.
268). What is the method used to pause “data” events?
[A] s.pause();
[B]s.stop();
[C]s.halt();
[D] s.wait();
Show Answer
Correct Answer: s.pause();
Notes:
Answer: a
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.
269). 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);
Show Answer
Correct Answer: s.on(“end”,f);
Notes:
Answer: b
Explanation: ”EOF” stands for end of file.The above code snippet gets “end” event fired on EOF when no more data will arrive.
270). What will be the return value of the write() method when the Node cannot write the data immediately and has to buffer it internally?
[A]0
[B]1
[C]True
[D]False
Show Answer
Correct Answer: False
Notes:
Answer: d
Explanation: The write() method writes HTML expressions or JavaScript code to a document. The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML. write() method never blocks. If Node cannot write the data immediately and has to buffer it internally, the write() method returns false.
271). If the user presses “ok” in the dialog box then what will be the output of the following JavaScript code?
function msg()
{
var v= confirm("Are u sure?");
if(v==true)
{
alert("yes");
}
else
{
alert("no");
}
}
[A]true
[B]yes
[C]no
[D]undefined
Show Answer
Correct Answer: yes
Notes:
Answer: b
Explanation: The function confirm is present in the window object. confirm() method displays the confirm dialog box containing a message with ok and cancel button.
272). What will be the output of the following JavaScript code?
document.writeln("navigator.appCodeName: "+navigator.appCodeName);
[A]Browser name
[B]Version
[C]Error
[D]Undefined
Show Answer
Correct Answer: Browser name
Notes:
Answer: a
Explanation: The JavaScript navigator object is used for browser detection. appCodeName returns the browser name.
273). What will be the output of the following JavaScript code?
document.writeln("navigator.language: "+navigator.language);
[A]Broswer name
[B]Browser language
[C]Browser version
[D]Error
Show Answer
Correct Answer: Browser version
Notes:
Answer: c
Explanation: navigator.language returns the language of the browser. It is supported in Netscape and Firefox only.
274). What will be the output of the following JavaScript code?
document.writeln("navigator.appVersion: "+navigator.appVersion);
[A] Browser version
[B]Browser name
[C]Browser language
[D]Error
Show Answer
Correct Answer: Browser version
Notes:
Answer: a
Explanation: navigator.version is present in the navigator object. appVersion returns the version of the browser.
275). What will be the output of the following JavaScript code?
document.writeln("screen.width: "+screen.width);
[A]Browser length
[B]Browser width
[C]Browser area
[D]Error
Show Answer
Correct Answer: Browser width
Notes:
Answer: b
Explanation: screen.width method is provided in the screen object of Javascript. It returns the width of the browser screen