• 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 Classes

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused with the following terms used in reference to inner classes in the mock exams
- Nested top level inner class
- Member Inner class
- local class
- Local Inner class
Many Thanks
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- Nested top level inner class = top-level class defined within another top-level class. Kinda like making your own little namespace scope inside a class.
class Outer {
static class Nested {}
}
- Member Inner class = a class defined within another class class which is directly tied to an instance of the outer class. Think of it as a form of composition in which the type of the included object is defined in the holding type.
class Outer {
class Inner {}//no static keyword
}
- local class = not sure. perhaps, this should have been anonymous classes; if so, see below...
- Local Inner class = an inner class which has its instance tied to the scope of a method execution--albeit, the instance of the local class can be accessed outside the method's scope (read Java in a Nutshell for a good explanation).
class Outer {
void outerMethod1() { class Local{} }
}
- Anonymous class = a class without a name. These are very useful with event listeners. Here's an example:
Button b1 = new Button("Hey");
b1.addActionListener( new ActionListener()
{ public void actionPerformed(ActionEvent ae)
{
System.out.println("Oh my, someone hit button 1");
}
});
 
Lancy Mendonca
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a million for the reply
 
What's wrong? Where are you going? Stop! Read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic