There is no implicit sub-type relationship: your observation/conclusion is correct. (In the first case, super
has the type of "Object" and "Object.fruit" does indeed not exist.)
An inner class (as opposed to "static nested class"), as shown, must be created within context of an instance of the outer class; but this is orthogonal to sub-typing.
To access a member of the outer class, use OuterClass.this.member
or, if member
is not shadowed, just member
will resolve; neither super.member
nor this.member
will resolve to the outer class member.
Extending the outer class "fixes" the compiler error, but the code with this.fruit
doesn't access the member of the enclosing OuterClass instance - it simply accesses the member of the InnerClass instance inherited from the superclass it extends.