• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

AWT

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An application consists of a set of user interfaces & the various
operations are to be performed based on the various user invoked
events. Which of the following are true for the above application
(a) Extending Adapter classes is not suitable
(b) Some listener interface must be implemented
(c) If a particular event listener is implemented only the methods of
interest to us need to be implemented
(d) Multiple event listeners can be added to a single component
(e) The order in which the events are processed is the order in which
the listeners are added
Ans:a,d
It is a quite strange why a is right?
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say b & d are correct. Where is this question from? I've learned that a lot of these test questions are just plain wrong.
I suppose a could be correct under certain conditions, but based on the really vauge description of the application, I can't see how extending adapter classes wouldn't be appropriate. If you use an adapter as an annonymous class, that's extending an adapter and this happens all the time.
So I also don't see why a is wrong.
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ans a would seem to be incorrect because the q say many events are to be handled by the app, in which case cluttering you code with many anonymous "adopter" classes that require to be overridded makes the code hard to read if not maintain.
Adapter classes don't provide any functionality, and since you need to define event handlers it seems absurd to use adapter classes that don't do anything.
[ February 18, 2002: Message edited by: Rajinder Yadav ]
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob I agree with you that the ans should also be b & d
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the contrary, adapter classes help keep your code uncluttered.
If you want to attach a mouse listener to a component, you could do this:

but if all you really want is to handle a mouseClicked event, this is a lot of typing. A MouseAdapter would be more useful in this case:
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob what I stated in my previous post was that if you need to define "many" of these handlers that the adapter class does nothing for, then having to define handle function that actually do something would result in cluttered hard to read code that uses adaptets which you end up defining/overriding the methods for.
Using your MouseListener, try to think of a realword app that actaully does something for each of these events, would you use adapter classes when each event required something to be done, I don't think you would, would you!
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic