That's quite correct.
Claud Mann wrote:. . . static methods cannot be overridden.
Please avoid such images. As well as what that link says, such images disappear from the reply window, so i can't even readily see it.
. . . these lines of code (the image you can find as attachment). . .
No, he correctly said he isn't overriding those methods, but hiding them. This is what overriding means: the method used at runtime is found from the runtime type of the object, and that applies only to instance methods:-Try that code; you will get ??? printed.
. . . he ovverrode . . .
I have also heard people say, “late binding,” and, “runtime binding.” Which of the three terms do you think is best?
Junilu Lacar wrote:. . . a mechanism called "dynamic binding." . . .
Campbell Ritchie wrote:I have also heard people say, “late binding,” and, “runtime binding.” Which of the three terms do you think is best?
Junilu Lacar wrote:Another thing to note about static methods is that they're not polymorphic. That is, they are resolved at compile time rather than runtime.
Stephan van Hulst wrote:
The reason is because what matters is the class to which obj belongs, and not the type of the object instantiated.
Why? Because the method is a static method, so the Dynamic Method Lookup doesn't intervene.
Johnny Joseph wrote:Why does Java allows to override a static method which will not work ?
Is it possible to stop them in the compilation time itself?
Is there is any cases where static method overridden is going to work in java?
Catch what? There is no syntax error in such code. It obeys the behaviour specified for it in the Java® Language Specification exactly. If the behaviour is different to what I expected, that means I have programmed it wrongly.
Johnny Joseph wrote:. . . couldn't catch in during compilation itself?
A timing clock, fuse wire, high explosives and a tiny ad:
Two software engineers solve most of the world's problems in one K&R sized bookhttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton