This is a question from a mid-term I had awhile ago. I just want to hear what you guys think the answer is, because I just can't agree with the teacher on this.

A(n) ____ is a listener interface that listens for any events that occur during the execution of a program.

A. WindowListener
B. ActionListener
C. ItemListener
D. GarbageListener

The answer, according to her, is ActionListener. When I asked her to explain, she said the other answer were just made up classes anyway so ActionListener is the only possible solution. As far as I can tell, the question simply describes any kind of listener. Btw, I chose WindowListener with no real specific reason.

Recommended Answers

All 4 Replies

This is a question from a mid-term I had awhile ago. I just want to hear what you guys think the answer is, because I just can't agree with the teacher on this.

A(n) ____ is a listener interface that listens for any events that occur during the execution of a program.

A. WindowListener
B. ActionListener
C. ItemListener
D. GarbageListener

The answer, according to her, is ActionListener. When I asked her to explain, she said the other answer were just made up classes anyway so ActionListener is the only possible solution. As far as I can tell, the question simply describes any kind of listener. Btw, I chose WindowListener with no real specific reason.

That's a really dumb question. There is no listener that listen for ANY events. ActionListener only listens for action events?? I would have chose A..... The only made up listener is D. There is a windowListener and an itemlistener. (as far as i can remember?)

WindowListener listens for changes to the window like size and stuff

But those changes are still called events, that happen during execution.

Dumb question indeed, and ambiguous.

Depending on how you define and assign your Listeners, none listen to everything.
A WindowListener hooked to a dialogbox may for example never listen to anything if that dialog is never launched.

He probably did mean a WindowListener, but those are related to only a single Window, not an entire application.
When for some reason that window (even if it's the main application window) can't receive an event it won't register with the WindowListener.

Also, a WindowListener responds to only some very specific events, namely those events directly related to the Window itself (activation and deactivation), and not even all of those.

An ActionListener only responds to specific user events associated with specific controls.

An ItemListener only works for specific controls like JLists which can contain multiple items.

And a GarbageListener doesn't exist.

There is in fact no single Listener which listens for ALL events an application may receive, so the only correct answer would be "e: none of the above".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.