Override function | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Override function

Can you override a private or static method in Java?

11th Apr 2020, 6:51 PM
ekhlas Mohamed Abdallah Mohamed
ekhlas Mohamed Abdallah Mohamed - avatar
1 Resposta
+ 2
No you cannot override a private method in Java because the method is available to the class alone and cannot be inherited. Static methods are inherited but they cannot be overriden. If you declare the same method in the subclass then it will hide the super class method. This is also called method hiding.
11th Apr 2020, 6:59 PM
Avinesh
Avinesh - avatar