posted 21 years ago
abstract class A { // 1
private abstract void m1(); // 2
private abstract class B {} // 3
private class C extends B {} // 4
}
line //2 (generates compile error):
private and abstract are mutually exclusive modifiers for methods. The private modifier indicates nobody outside of me should see it. The abstract modifier for methods indicates, someone down the line in my class hierarchy should provide the implementation.
line //3 (legal):
class A wants to have an abstract template, which it can use to define some classes. Class A decides that outside the scope of class A, the template (i.e., abstract class B) hasn't got a meaning. So, class A keeps it encapsulated within its boundary.
line //4 (legal):
You can define a private class within a class. It is perfectly legal for class C to extend from private class B as the scope of B is the entire body of class A.
[ December 08, 2002: Message edited by: Abu Yoosuf ]