sai rama krishna wrote:I agree
// it's a redefinition,
// not an override
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.
As another hint, even though another rancher kinda gave you the answer, what is the type of the reference being used to call the 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.
Correct me if i missed something..
That looks correct to me
Chetan Dorle wrote: . . . Animal's method will be called. . . .
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.