Return to site

Can you override a static method in Java?

August 4, 2025

๐Ÿš€ Java Interview Questions โ€“ Episode 7
๐Ÿ’ก Can you override a static method in Java?
โŒ No, you canโ€™t override static methods in Java.

Why?
Because static methods are resolved at compile time, not runtime. That means they belong to the class, not the instance.

๐Ÿงฉ What can you do?
You can declare a static method with the same signature in a subclass โ€” but this is called method hiding, not overriding.

๐Ÿ“Œ Key takeaway:
Overriding = instance method (polymorphism)
Hiding = static method (no polymorphism)
Understanding this difference is crucial when dealing with inheritance in Java.