An interface that extends multiple interfaces

Below code

interface I3{
    boolean abc();
}; 
interface I2{
    void abc();
};
public class Example1  implements I3, I2{
    @Override
    public void abc() {
        //Eclipse IDE picked this unimplemented method with the compiler error

    }
}

      

Is the programmer obligated not to get into this situation?

Why does Java allow interface extending multiple interfaces? when is java already avoiding the similar problem of a class inheriting multiple superclasses?

In the case of such constants inherited from multiple interfaces, interfacename.constantname

the subclass avoids ambiguity.

+3


source to share


2 answers


Yes, it is definitely the programmer's defendant not to get into this situation.



An interface is a way to have multiple inactivity, we should not confuse the JVM with such conflicts.

0


source


because both methods abc()

have the same signature (the return type is not part of the method signature) and java cannot distinguish between subject and this situation causes conflict



-1


source







All Articles