oh..that's hard. I got this from a book fondly called 'Question500' issued by an institute for java studies in sri lanka. (IJTS) hope that's specific enough
Joined: Oct 30, 2008
Oww, sorry for that. But it is the rule..
About the question: Overriding is always resolved at runtime, and since you have a reference to the object "D" (and it doesn't matter what is the type you are referring to), you will get the overriding method.
Here the explicit casts are useless as they are only used by the compiler to resolve whether class C, B and A have a method m1() defined in it. At runtime it is only the actual object type which is used to invoke the method which in this case is object of class D referred by this
Joined: Dec 09, 2008
oh ok.. its clear now. Thank you both, Djonatah and Harvinder :-)