It's true that the method is not overridden. I believe the term the JLS uses is "hiding". There's "hiding", "shadowing", and I think one more similar term. They describe similar situations, but I don't recall the finer details of which term applies to which cases.
Jeff Verdegan wrote:There's "hiding", "shadowing", and I think one more similar term.
There's hiding, shadowing and obscuring. For day-to-day programming, it's not that important to know the exact rules for these (you can look them up if you get into a situation where they play a role).
Yes , As Henry suggested , static method require only reference variable , So they check which Class reference is used and not the object associated with that reference which is reverse of instance method.
Again if you put like Animal a=null; then also it will give you proper result .
So obviously Animal  a variable is used so always Animal's method will be called.
Chetan Dorle wrote: . . . Animal's method will be called. . . .
That looks correct to me
But I still think it is better to follow the advice in Bloch and Gafter’s Java Puzzlers book and avoid hiding shadowing and obscuring as far as possible. This thread shows exactly why that is good advice.
Rajiv Rai wrote:Is the output what it is, because the methods are redefined and not over-ridden.
Sort of. It's part of the same set of rules. You're getting the output you are because for static methods, which class's version of the method to invoke is determined at compile time, by the type of the reference. I believe this was already stated a couple of times here. Is there some part of it you don't understand?
I would say that the fact that the method ends up being hidden, rather than overridden, is a consequence of the above rule, rather than the root cause of what you're seeing.
Stinging nettles are edible. But I really want to see you try to eat this tiny ad: