why does this code compile printing "Class 2" (java se8; eclipse) even if abstract method is NOT implemented in first concrete class?
IDE gives me the hint: The type Class1 must implement the inherited abstract method Interface1.method1()
package uebungen.u025;
interface Interface1 {
public void method1();
}
interface Interface2 extends Interface1 {// line n1
public void method2();
}
class Class1 implements Interface2 {// line n2
@Override
public void method2() {
System.out.println("Class 1");
}
}
class Class2 extends Class1 {// line n3
@Override
public void method2() {
System.out.println("Class 2");
}
}
public class Test {
public static void main(String[] args) {
Class1 x = new Class2();
x.method2();
}
}