+ 5
Can we override a private or static method in Java?
3 ответов
+ 4
In static method it is not an override. you are just defining a static method with the same method name and parameters. by override we mean polymorphism in OOP that is the ability to establish which method of an object to execute at runtime. in the static field, however, this is decided during compilation since the name of the method is given by its name together with the name of the class it belongs
you cannot override a private method because as private it is not visible to the subclass
+ 3
We can write same static method in super class and subclass but it is not calling Overriding.
Checkout this for more. you will understand better.
https://uniquethrowdown.blogspot.com/2021/01/java-interview-questions-on-static.html
0
hi