Hi,
Here derived class object is referred to a base class type reference variable which is perfectly legal.
when we invoke a method on this type of variable, at compile time JVM looks for the method in base class, and since it exists it compiles. also static methods and instance variables all are invoked at compile time which means, base class values are invoked.
but actually in runtime, the method in the object which is being passed to this variable is invoked for instance methods.
this is also called runtime polymorphism or dynamic method dispatch.
Srinivas
SCJP1.4
[ January 24, 2006: Message edited by: Srinivas Tuta ]
[ January 24, 2006: Message edited by: Srinivas Tuta ]