I have a sub class, subClass1 that has a protected attribute, subAtt. The
sub class uses super() in the constructor. If I instantiate the super
class, why can't I see the subAtt attribute ?
> I have a sub class, subClass1 that has a protected attribute, subAtt. The
> sub class uses super() in the constructor. If I instantiate the super
> class, why can't I see the subAtt attribute ?
Because the sub class "is a" super class - but a super class isn't
necessarily a sub.
Consider
A Class Pet, and a class Dog which extends Pet, and a class Cat which
extends Pet, a Parrot class the extends Pet, etc - any number of different
classes that extends Pet...
a Dog instance 'is a' Pet
but
a Pet instance could be a fish, a cat, or Parrot.
If you cast the Pet to a Dog, then you may be able to call your method.
HTH