+ 5

Can we override a private or static method in Java?

18th Jun 2021, 3:58 AM
RuBeen Dahal👿
3 Respuestas
+ 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
18th Jun 2021, 5:39 AM
Ciro Pellegrino
Ciro Pellegrino - avatar
+ 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
19th Jun 2021, 5:40 AM
Java Developer
Java Developer - avatar
0
hi
25th Jun 2021, 1:29 PM
Alexandra Tindoc
Alexandra Tindoc - avatar