Overriding Default Methods – Object-Oriented Programming
Overriding Default Methods Overriding a default method from an interface does not necessarily imply that a new implementation is being provided. The default method can also be overridden by providing an abstract method declaration, as illustrated by the code below. The default method printSlogan() at (1) in the interface ISlogan is overridden by an abstract method declaration at (2) and (3) in the interface INewSlogan and the abstract class JavaMaster, respectively. This strategy effectively forces the subtypes of the interface INewSlogan and of the abstract class JavaMaster to provide a new concrete implementation for the method, as one would expect for an abstract method. Click here to view code image interface ISlogan { default void printSlogan() { // (1) Default method. System.out.println(“Happiness is getting certified!”); }}interface INewSlogan extends ISlogan { @Override abstract void printSlogan(); // (2) overrides (1) with abstract method.}abstract class JavaMaster implements ISlogan { @Override public abstract void…