It it possible to override static methods in Java? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grátis
+ 2

It it possible to override static methods in Java?

https://code.sololearn.com/c5qiFCG71pXY/?ref=app It is work. Why not?

2nd Oct 2020, 2:00 PM
Элеонора Сергеева
Элеонора Сергеева - avatar
6 Respostas
+ 9
Eleonora Lyonesse In Java, we can declare a static method in the child class with the same signatures as in Parent class. But it will not be considered the method overriding. The static method of child class will hide the implementation of the method of Parent class. It is known as method hiding. Because the compiler decides which method to execute at the compile-time, not at the runtime. As you know the static method can be accessed by class name rather than the object. When the compiler invokes the static method then it accesses the static method of the child class. For more details with example: https://javagoal.com/can-we-override-the-static-method-in-java/
4th Oct 2020, 3:05 AM
Raina Dhankhar
Raina Dhankhar - avatar
+ 8
Eleonora Lyonesse Apparently in your example that is called Method Hiding and not method overriding. Take a look 👇 https://www.tutorialspoint.com/What-is-method-hiding-in-Java-and-how-to-use-it#:~:text=Java%208Object%20Oriented%20Programming,is%20known%20as%20method%20hiding. Static methods can't be overridden. Please check these posts too👇 https://www.sololearn.com/post/225388/?ref=app https://www.sololearn.com/post/225380/?ref=app Credit : P∆WAN M∆URY∆ 🙏
2nd Oct 2020, 2:48 PM
Minho
Minho - avatar
2nd Oct 2020, 2:06 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
https://www.sololearn.com/post/634447/?ref=app
2nd Oct 2020, 3:18 PM
Элеонора Сергеева
Элеонора Сергеева - avatar
+ 2
ok, thanks!!!)
2nd Oct 2020, 3:23 PM
Элеонора Сергеева
Элеонора Сергеева - avatar
+ 2
I think, Ulyana Sveleba confused overloading and overriding in the questions (SoloLearn challenges)
2nd Oct 2020, 3:35 PM
Элеонора Сергеева
Элеонора Сергеева - avatar