Interface Default and Static Methods in Java 8

Before Java 8, interfaces could have only public abstract methods.

It was not possible to add new functionality to the existing interface without forcing all implementing classes to create an implementation of the new methods, nor it was possible to create interface methods with an implementation.

Starting with Java 8, interfaces can have static and default methods.

The static method can not be overridden in the implementing classes whereas the default method can be overridden in the implementing classes.

Let’s look into the below example for better understanding.

E77

Output

O7

Leave a Reply

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