If a type implements two interfaces, and each interface defines a method that has an identical signature, then in fact there is only one method, and they are not distinguishable. If, say, two methods have conflicting return types, then this will be a compilation error. This is a general rule of inheritance, method overriding, hiding and declarations, and also refers to possible conflicts not only between two inherited methods of an interface, but also an interface and a superclass method, or even just conflicts due to erasing generic types.
Compatibility example
Here is an example in which you have a βGiftβ interface that has a present () method (just like when giving gifts), as well as a βGuestβ interface that also has a present () method (for example, a guest is present and not absent) .
Presentable johnny is a gift and a guest.
public class InterfaceTest { interface Gift { void present(); } interface Guest { void present(); } interface Presentable extends Gift, Guest { } public static void main(String[] args) { Presentable johnny = new Presentable() { @Override public void present() { System.out.println("Heeeereee Johnny!!!"); } }; johnny.present();
The above snippet compiles and runs.
Please note that only one @Override is needed !!! This is because Gift.present () and Guest.present () are "@ Override-equivalent" (JLS 8.4.2).
So johnny has only one implementation of present (), and it doesn't matter how you feel about johnny, whether it is a gift or as a Guest, there is only one method to call.
Incompatibility example
Here is an example where there are two inherited methods: NOT @ Override equivalent:
public class InterfaceTest { interface Gift { void present(); } interface Guest { boolean present(); } interface Presentable extends Gift, Guest { }
This once again confirms that the inheritance of members from the interface must obey the general rule for declaring members. Here we have Gift and Guest define present () with incompatible return types: one void another logical. For the same reason that you cannot use void present () and boolean present () in the same type, this example leads to a compilation error.
Summary
You can inherit methods equivalent to @Override, given the usual requirements of overriding and hiding a method. Since they are ARE @ Override-equivalent, only one method is effectively implemented and, therefore, there is nothing to distinguish / choose from.
The compiler does not need to determine which method is for which interface, because once they are defined as equivalent by default, they are the same method.
Resolving potential incompatibilities can be challenging, but this is another problem.
References
http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.8.4