I believe the quoted answer refers to scenarios like this in Java: 1
interface B { default void x() { System.out.println("B::x"); } } interface C { default void x() { System.out.println("C::x"); } } class D implements B, C {}
What will new D().x() do here?
Fortunately, the compiler completely prohibits the definition of D with the following message:
D inherits unrelated defaults for x() from types B and C
You can eliminate the ambiguity (and satisfy the compiler) by overriding x in D You can then explicitly call the individual inherited methods by default:
class D implements B, C { @Override public void x() { B.super.x();
<sub> 1. It is clear that there is no diamond. But this is an even simpler case. We could add interface A { void x(); } interface A { void x(); } that both B and C expand, but this will not change the result.
source share