I am learning java and I am trying to recreate a scenario where A class is extending an abstract class and also implementing an interface. Each abstract class and interface have a same method defined in them. Now from the class which is extending and implementing, I want to call the implementations of both the parents. I tried to recreate this scenario as below but it gave me the error: not an enclosing class: A
interface C {
default void m1(){
System.out.println("C");
}
}
abstract class A{
abstract void display();
void m1(){
System.out.println("A");
}
}
class B extends A implements C{
public void m1(){
}
void display() {
C.super.m1();
A.super.m1(); // error: not an enclosing class: A
}
}
public class Main {
public static void main(String[] args) {
A obj = new B();
obj.display();
}
}