This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The static method declared in class cannot hide the instance method of the same signature declared in its super class. The instance method declared in class cannot override the static method of the same signature declared in its superclass. Whats the reason behind it?
1) Static methods are resolved at compile time, instance methods are "late binding" which means that they are not resolved until runtime, and at runtime the JVM decides between the available methods which one is appropriate. 2) Static methods are always invoked without reference to a particular instance, and instance methods are always invoked with reference to a particular instance. 3) Static methods get loaded to the method area at class load time, instance methods get loaded to the method area at the last possible minute before execution. Since in either case you describe, one of the methods is static, there is no way for late binding to occur, because the static one is not available as a choice anymore (it's already in place). The JVM just can not handle that situation, so instead the compiler handles it by causing a compile time error.
"JavaRanch, where the deer and the Certified play" - David O'Meara