Forums Register Login

Javacap mock test que-27

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
thanx kathy
Just the other day, I was thinking ... about this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1111 times.
Similar Threads
listeners
Question
Listners
event handling
JavaCaps mock 1 Q:27
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:29:02.