by "static" i mean "compile time type." (whoops! "static" has a
special syntactic meaning in java doesn't it?) that is, bc is
declared to be BaseClass; the compiler types each occurance of
the identified "bc" as "BaseClass." the fact that at run-time bc
actually refers to a DerivedClass instance matters only when
an overriden method is being invoked.
so as far as the compiler is concerned, you're trying to
invoke a protected method of a BaseClass from inside the
definition of DerivedClass. that's not allowed, unless
BaseClass and DerivedClass are in the same package.
the other way around is ok. if bc was declared to be
DerivedClass, and the invocation bc.protectedMethod() occured
in the definition of BaseClass, all would be fine.
"lrm" is "language reference manual" -- i.e., "The Java
Language Specification 2nd Edition."
sorry about the confusion :-0
------------------
Fred Hosch
Author of:
An Introduction to Software Construction with Java