• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javacap mock test que-27

 
mads pawar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
27. What is correct about event handling in Java?
A) Java 1.0 event handling is compatible with event delegation model in Java 1.1
B) Java 1.0 and Java 1.1 event handling models are not compatible
C) Event listeners are the objects that implements listener interfaces.
D) You can add multiple listeners to any event source, then there is no guarantee that the listeners will be notified in the order in which they were added.
ans given B,C,D,
I think c is not correct
listeners are itself interface. or it should be like
Adapter classes implements listener interface
//please explain whether i am right or wrong.
 
Kathy Rogers
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think c is correct - quoting from RHE, "An event listener is an object to which a component has delegated the task of handling a particular event".
So when you do
class MyListener implements ActionListener{
public void actionPerformed(ActionEvent ae)
{
// some code here
}
}
and then in another class create an object of MyListener and use it as the ActionListener for a button:-
MyListener listen = new MyListener();
myButton.addActionListener(listen);
listen is the event listener. Cos listen is what myButton has delegated the task of handling action events to. Instances of Adapter classes could also be used as event listeners - although there wouldn't be much point as they wouldn't do anything. It is a bit confusing because of all the listener interfaces!
Kathy
 
mads pawar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx kathy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic