I have an interface A
with a default method printme()
, same method I am having in an abstract class B
. If I am extending abstract class B
with a TestClass
and implementing interface A
, printme()
method is not visible in TestClass
.
Below is code:
interface A {
default void printme() {
System.out.println("Interface A");
}
}
abstract class B {
public void printme() {
System.out.println("Abstract Class B");
}
}
public class TestDefaultMethod extends B implements A {
public static void main(String[] args) {
TestDefaultMethod td = new TestDefaultMethod();
td.printme(); //from Interface A
}
}
I am not able to understand how and why I am not able to access method from Abstract class.