Compiling and running this code prints: From SuperTest
Q. Can someone please explain why it prints "From SuperTest" and not "From SubTest" since the inherited instance method printa() is invoked on subclass reference type which I think should be considered for invoking the "redefined / redeclared" static method defined in the subclass??
Once you over ride the method printa() , the method a() in the sub class will get called from the subclass version of printa() . Else the method in the super class is called. So when the method is over ridden it prints "From SubTest".
Joined: May 16, 2006
Sorry, I meant to ask if you could elaborate on why it prints "From SuperTest" not "From SubTest". Can anyone tell me why?