Interaction between extended class and implemented interface

Viewed 263
public class Main {

public static class ClassBase {

    public void test() {
        System.out.println("1");
    }

}

public static interface Interface {

    default void test() {
        System.out.println("2");
    }

}

public static class MyClass extends ClassBase implements Interface {

}

public static void main(String[] args) {
    new MyClass().test();
}

}

In this example, it will always print 1. To print 2, I must override test in MyClass and return Interface.super.test().

Is there a way of making the Interface::test method override the ClassBase::test method without manually overriding the method in MyClass ? (to print 2 in the example)

1 Answers
Related