1. class Outer {
2. class Inner { }
3. }
4.
5. public class InheritInner extends Outer.Inner {
6. InheritInner () { }
7.
8. public static void main(String [ ] args) {
9. Outer o = new Outer( ) ;
10. InheritInner ii = new InheritInner( ) ;
11. }
The above code is from
http://www.akgupta.com/Java/mock_exam.htm mock exam
Qno 38
It throws a error at compile time saying that
InheritInner.java:7: an enclosing instance that contains Outer.Inner is required
InheritInner () {
My question is can we inherit a inner class? If we can then why need the concept of inner class?
Thanks in advance for the help