File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inner classes" Watch "Inner classes" New topic

Inner classes

Sricharan Modali

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.

SCJP Tipline, etc.
I agree. Here's the link:
subject: Inner classes
It's not a secret anymore!