I know that in case of dynamic binding only those method which are present in current class can be called. If child override parent method then the child method is executed otherwise parents method will be executed…
But in case of interfaces what is happening I don’t know… Here’s an example of what I mean:
interface TestInterface {
public void show();
}
class Test implements TestInterface {
public void show() {
System.out.println("Hello in show");
}
public String toString() {
System.out.println("Hello in To String");
return "";
}
public static void main(String[] args) {
TestInterface obj = new Test();
obj.show();
obj.toString(); // why it run vilate dynamic binding rule..
}
}
In case of interfaces in java :-“All interfaces get all public and abstract method of Object class”