0

Can we overide static methods?...

Java

4th Jul 2019, 8:23 AM
Nag Raj
3 Réponses
+ 6
No, static methods can't be overridden, but they can be hidden.
4th Jul 2019, 8:53 AM
voja
voja - avatar
0
you can override static method with static method if you call it static way public class A { static String method() { return "A"; } } public class B extends A { static String method() { return "B"; } public static void main(String[] args) { System.out.println( B.method() ); // B } }
4th Jul 2019, 11:02 AM
zemiak