I have an interface(A) the contain method myMethod() and a class(B) also contain the same method myMethod() and another class(c) extends and implement A and B.
No i created the object of class A a = new C()
and call the a.myMethod();
.
How it is executing the myMethod of class B.
interface A {
void myMethod();
}
class B {
public void myMethod() {
System.out.println("My Method");
}
}
class C extends B implements A {
}
class MainClass {
public static void main(String[] args) {
A a = new C();
a.myMethod();
}
}
Output of the program -
My Method