ExamVeda
Login
Home
1
What are the events generated by the Node objects called?
Discuss
Answer & Solution
Answer: Option B
Solution:
Node objects that generate events (known as event emitters) define an on() method for registering handlers.
2
What is the function used to deregister event handler ‘f’?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
3
What is the function used to remove all handlers for name events?
Discuss
Answer & Solution
Answer: Option D
Solution:
The removeAllListeners(name) is used to remove all handlers from name events represented as :
emitter.removeAllListeners(name)
4
Which function is a synonym for on()?
Discuss
Answer & Solution
Answer: Option A
Solution:
The on() method is used for registering handlers. addListener() is a synonym for on().
5
Which of the following is an event emitter?
Discuss
Answer & Solution
Answer: Option B
Solution:
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().
6
When do uncaught exceptions generate events?
Discuss
Answer & Solution
Answer: Option A
Solution:
Uncaught exceptions generate events, if any handlers are registered. Otherwise, the exception just makes Node print an error and exit.
process.on("uncaughtException", function(e) { console.log(Exception, e); });
7
Which among the following POSIX signals generate events?
Discuss
Answer & Solution
Answer: Option C
Solution:
The SIGINT is a POSIX signal that generates event.
8
What is the method used to pause “data” events?
Discuss
Answer & Solution
Answer: Option A
Solution:
The above code snippet is used to pause data events, for throttling uploads, e.g.
9
When the “end” event fires on EOF when no more data will arrive, which function is called?
Discuss
Answer & Solution
Answer: Option B
Solution:
The above code snippet gets “end” event fired on EOF when no more data will arrive.
10
What will be the return value of the write() method when the Node cannot write the data immediately and has to buffer it internally?
Discuss
Answer & Solution
Answer: Option D
Solution:
The write() method never blocks. If Node cannot write the data immediately and has to buffer it internally, the write() method returns false.