• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

What do you think of the answer to this question about listener?

Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this question from one of my favorite SCJP websites. It has an answer, but I doubt it, so I put this question again.
Which statements about listeners are true?
a. At most one listener can be added to any single component.
b. If multiple listeners are added to a single component, the order of invocation of the listener is not specified.
c. The return value from a listener is used to control the invocation of other listeners
d. In the java package, listener methods generally take an argument which is an instance of the some subclass of java.awt.AWTEvent class
They said the answer were b,d. Yes, I agree to b, but I'm not sure of d. Can somebody give me an answer for this?
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Woo,
If d was not true then your listener would be clueless as to what brought it there. For example:
WindowListeners expect WindowEvent to figure out what window event called the listener method
ActionListeners expect ActionEvent to figure out what action event called the listener method.
ComponentListeners expect ComponentEvent to figure out what component called the listener method.
KeyListeners expect KeyEvent to figure out what key was pressed.
MouseListeners expect MouseEvent to figure out what mouse button was pressed.
All xxxxxEvent are subclasses of java.awt.AWTEvent class.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic