+ 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 Answers
+ 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