Return to site

[VV127] The Java 21 Newsletter: ๐Ÿ’ป Java Interfaces: Can You Override That Method? Let's Set the Record Straight

August 31, 2025

Interfaces in Java can now do much more than just define abstract methods. Since Java 8+, we can also use default, static, and even private methods โ€” and when interfaces extend each other, you may wonder:

Can this method override that one?

Letโ€™s answer that with a definitive override matrix โœ…โŒ

๐Ÿงช Reference Interface

Weโ€™ll use this base interface to discuss method overrides:

Now, say we create a subinterface:

๐Ÿ“Š Override Possibilities Matrix

๐Ÿ” Hiding means the static method is not overridden but redefined in the subinterface or implementing class.

๐Ÿ’ก Examples

โœ… Valid

โŒ Invalid

๐Ÿง  Key Takeaways

  • โœ… You can override abstract or default methods with abstract or default.
  • โŒ You cannot override them with static.
  • โœ… You can redeclare static or private methods as any type โ€” but they do not override, just hide or coexist.
  • ๐Ÿ“Œ Private methods are invisible to the subinterface, so any redefinition is treated as a new method.

๐Ÿงพ Save This Matrix!

๐Ÿ”– Tags

#Java #JavaInterfaces #Java8 #Java21 #JavaCertification #OverrideVsHide #SoftwareEngineering #CleanCode #JavaTips #TechInterview

Go further with Java certification:

Java๐Ÿ‘‡

Spring๐Ÿ‘‡