Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

What is the `events` module used for in Node.js?
A. To handle HTTP requests
B. To work with the event emitter pattern
C. To manage file system events
D. To schedule timers
Direction: Choose the correct option

Q2.

How do you create an event emitter instance?
A. const emitter = events.create();
B. const emitter = require('events')();
C. const EventEmitter = require('events'); const emitter = new EventEmitter();
D. const emitter = new events();
Direction: Choose the correct option

Q3.

Which method is used to listen for an event?
A. Both B and C
B. emitter.once()
C. emitter.emit()
D. emitter.on()
Direction: Choose the correct option

Q4.

What does `emitter.emit('event', data)` do?
A. It creates a new event
B. It checks if an event exists
C. It removes all listeners
D. It triggers all listeners for 'event' and passes data
Direction: Choose the correct option

Q5.

How can you remove a specific listener?
A. emitter.removeAllListeners(event)
B. emitter.off(event, listener)
C. Both A and B
D. emitter.removeListener(event, listener)