• 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

Inner class

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why would a responsible Java programmer want to use a nested class?

A.To keep the code for a very specialized class in close association with the class it works with. //correct
B.To support a new user interface that generates custom events.
//not getting
C.To impress the boss with his/her knowledge of Java by using nested classes all over the place.

Given answer A,B.
Can any one explain what they really meant by B??
This question is from http://home-1.worldonline.nl/~bmc88/java/q_a/index1.html
Qn # 21
 
Mani
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry!!
Qn no:51
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by bongadi:
He is talking about Anonymous inner (nested) class here.
These are used (traditionally) to add the action listner
for the components.
Example:
Here I am adding an actionListner to the button searchButton.
<pre>
<code>
searchButton.addActionListener ( new ActionListener() {
public void actionPerformed ( ActionEvent e ) {
PerformSomeAction();
}
});
</code>
</pre>
The "new" in the code is to instantiate an inner class
with no name (anonymous inner class) which is implementing
ActionListener() interface.
So, you can have any custom component generating custom events
with a customized method to add listners for thoes events.[/B]


[This message has been edited by bongadi (edited April 21, 2000).]
[This message has been edited by bongadi (edited April 22, 2000).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic