Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inner Classes" Watch "Inner Classes" New topic

Inner Classes

Lancy Mendonca
Ranch Hand

Joined: Aug 08, 2000
Posts: 54
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

Sun Certified Java Programmer<BR>Oracle Certified DBA
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
- 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

Joined: Aug 08, 2000
Posts: 54
Thanks a million for the reply
It is sorta covered in the JavaRanch Style Guide.
subject: Inner Classes
Similar Threads
error message why?
Inner class
Examples of all the types of inner classes
A basic concept
Inner classes