Java Event Handling Question and Answers

5. What is the purpose of the enableEvents() method?
 
  • The enableEvents() method is used to enable an event for a particular object.
  • Normally, an event is enabled when a listener is added to an object for a particular event.
  • The enableEvents() method is used by objects that handle events by overriding their event dispatch methods.
 
Your Name Your Email-ID
Your Answer
6. What are the advantages of the model over the event inheritance model?
  The event delegation model has two advantages over the event inheritance model. They are
  • It enables event handling by objects other than the ones that generate the events.
  • This allows a clean separation between a components design and its use.
  • It performs much better in applications where many events are generated.
  • This performance improvement is due to the fact that the event delegation model does not have to be repeatedly process unhandled events as is the case of the event inheritance.
 
Your Name Your Email-ID
Your Answer
7. What event results from the clicking of a button?
  The ActionEvent event is generated as the result of the clicking of a button.
 
Your Name Your Email-ID
Your Answer
8. What is source and listener?
 
  • Source: A source is an object that generates an event. This occurs when the internal state of that object changes is some way.
  • Listener: A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events.
  • Second, it must implement methods to receive and process these notifications.
 
Your Name Your Email-ID
Your Answer
123 Page 2 of 3