+ 3

Can we override private or static method in java?

Method Overriding in which have method got same name & same parameters...

20th Feb 2018, 3:23 PM
Ajay Verma
Ajay Verma - avatar
2 ответов
+ 14
Static methods also cannot be overridden, because static methods are a part of the Class itself, and not a part of any instance(object) of that class. You however can declare samestatic method with same signature in child classes, but that would not be considered as runtime polymorphism (override ofmethods) . https://www.geeksforgeeks.org/can-we-overload-or-override-static-methods-in-java/ https://www.geeksforgeeks.org/can-override-private-methods-java/ https://www.sololearn.com/learn/Java/2165/?ref=app
20th Feb 2018, 3:34 PM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
+ 2
private methods arent visible to subclasses so no. overriding statics makes no sense because you need to specify the class by calling them which destroys the purpose.
20th Feb 2018, 3:35 PM
Jeremy
Jeremy - avatar