• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listeners.Frank, Frank, Frank Please help me!!!!!!!!!!

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which statement is true about writing a class, that handle event issued by a user interface component ?
A. Subclassing an Adapter is inappropriate in this case
B. The class should implement some listener interface
C. A class can implement multiple listener interfaces if desired
D. A Subclass of an AWT component cannot listen to its own events
E. When implementing a listener interface, the class will only provide those handler methods that it chooses.
Is it B) and C).
Frank Please help me with this question?
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I missed this when it arrived. I must have been busy with real life
Anyway.
A. is false. Subclassing an Adapter is a very popular way of writing an event listener.
B. is true. In order to get any event, your class must implement an appropriate Listener interface.
C. is true. As with all interfaces, a class my implement as many as required.
D. is false. Listening to one's own events is sometimes a useful idiom.
E. is false. As with any interface, a class which implements it must provide implementations of all methods in the interface. The deliberate confusion in this question is with Adapter classes. It is true that when implementing a subbclass of an Adapter, the class need only provide those handler methods that it chooses.
So your answer of B and C is correct.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frank:
why did you say B is correct? the class does not have to implement listener interface, it can just extends Adaptor too, am I right?
I think "should" == "must"
what do you think?
Vivian

Originally posted by Frank Carver:
posted January 26, 2000 11:26 AM
Which statement is true about writing a class, that handle event issued by a user interface component ?
A. Subclassing an Adapter is inappropriate in this case
B. The class should implement some listener interface
C. A class can implement multiple listener interfaces if desired
D. A Subclass of an AWT component cannot listen to its own events
E. When implementing a listener interface, the class will only provide those handler methods that it chooses.
Anyway.
A. is false. Subclassing an Adapter is a very popular way of writing an event listener.
B. is true. In order to get any event, your class must implement an appropriate Listener interface.
C. is true. As with all interfaces, a class my implement as many as required.
D. is false. Listening to one's own events is sometimes a useful idiom.
E. is false. As with any interface, a class which implements it must provide implementations of all methods in the interface. The deliberate confusion in this question is with Adapter classes. It is true that when implementing a subbclass of an Adapter, the class need only provide those handler methods that it chooses.
So your answer of B and C is correct.[/B]


 
Rancher
Posts: 241
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vivian, the Adapter class implements the Listener interface already, so when you extend that class, you are (tacitly?) implementing the Listener interface.
Check http://java.sun.com/products/jdk/1.2/docs/api/java/awt/event/MouseAdapter.html
for an example, at the top it says "implements MouseListener"
Eric B.
 
reply
    Bookmark Topic Watch Topic
  • New Topic