Hi, Ernest, see the following code and try to get the understanding:
That means, you can access protected members of superclass by using the reference of its subclass object, not the superclass object itself.
Hope it helps.
Guoqiao
Originally posted by Ernest Lee:
Can anyone explan the following to me??
Protected?means all classes in the same package (like default) and sub-classes in any package can access the features. But a subclass in another package can access the protected members in the super-class via only the references of subclass or its subclasses. A subclass in the same package doesn�t have this restriction. This ensures that classes from other packages are accessing only the members that are part of their inheritance hierarchy.
Thx!
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum