Meaningless Drivel is fun!*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inner classes" Watch "Inner classes" New topic
Author

Inner classes

Sricharan Modali
Greenhorn

Joined: Mar 30, 2004
Posts: 19
If an inner class is like a instance method(it can have modifiers like abstract, private etc) of the enclosing class then - why when an inner class is declared abstract the enclosing class need not be declared abstract?
for example
class Outer
{
abstract class Innner
{
}
}
complies fine!?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
An inner class is like a member method in the fact that it can have access modifiers, but it is still very different from a method.
If you declare a member method to be abstract, you are saying that the method can not be invoked by an instance of this class. Rather, you need some other class to override that method. Therefore, you have defined an "incomplete" class - one that can not be fully implemented. As such, you are required to mark the class as abstract.
However, if you have an abstract class within an enclosing class, there is no problem with the enclosing class. All of its member methods can be invoked properly, etc.
I suggest you check out the JLS, §8.1.2 Inner Classes and Enclosing Instances and Getting in Touch with your Inner Class in order to get a better understanding of some of the details pertaining to inner classes.
Corey


SCJP Tipline, etc.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inner classes
 
Similar Threads
INNER CLASSES
local inner classes
abstact private
abstract inner class??
Can we access enum with object of d class?