Can we override static method in Java?

By | August 9, 2019

In this post we will discuss about one of very tricky core java interview question and question is that Can we override static method in Java?

This is the trickiest Java interview question.

Static methods cannot be overridden in the exact sense of the word, but they can hide parent static methods.

Parent class static methods are not part of a child class (although they are accessible), so there is no question of overriding it. Even if you add another static method in a subclass, identical or with same method signature to the one in its parent class, this subclass static method is unique and different from the static method in its parent class.

This Java Program will show that, we can not override static method in Java. If you declare same method in subclass then It is known as method hiding.

 Output of above program:

You May also like:

Can we call static method with null object?

That’s all about  Can we override static method in Java?
If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *