It will awesome if I can apply a refer to a default implementation to the interface in the following program using super
. Like Alpha.super.reset()
so, plz tell us where this statement will be use.
interface Alpha {
default void reset() {
System.out.println("This is alpha version of default");
}
}
interface Beta {
default void reset() {
System.out.println("This is beta version of default");
}
}
class MyClass implements Alpha, Beta {
void display() {
System.out.println("This is not default");
}
}
class MainClass {
public static void main(String args[]) {
MyClass ob = new MyClass();
ob.reset();
ob.display();
}
}
For example if we want to use the beta version of reset()
method, then we have to extend one of them two interfaces. For example : interface Beta extends Alpha
then it will use the beta version of reset()
. But here we want to use the super and where it will be use.