Absolutely the right question.
Here, both the interface and the abstract class have the same method.
You have one class name, this is hello, extends the abstract class and implements its true interface, and you redefine the met1 method to the hello class, and its compilation is correct and no error is given, but it cannot determine which class method is overridden as an abstract class or interface.
This polymorphism at runtime you cannot create an object of an abstract class and interface, but you can create a reference variable. Here's the solution - you cannot determine that at compile time its actual redefinition at runtime.
interface hi { public void meth1(); } abstract class Hullo { public abstract void meth1(); } public class Hello extends Hullo implements hi { public void meth1(){ System.out.println("hello"); } hi h= new Hello(); h.meth1();
source share