Polymorphic method invocations apply only to instance methods. You can always refer to an object with a more general reference variable type (a superclass or interface), but at runtime, the ONLY things that are dynamically selected based on the actual object (rather than the reference type) are instance methods. Not static methods. Not variables. Only overridden instance methods are dynamically invoked based on the real object's type. Can any one elaborate on above lines. Thanks in advance
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Only overridden instance methods are dynamically invoked based on the real object's type.
It means at runtime jvm will look reference inside the reference variable and will find out on the heap what is the actual object- subclass object or superclass object and then it will call the method on it.... so if there was subclass reference inside so subclass method will get execute... [ July 06, 2007: Message edited by: raj malhotra ]