I know that in the case of dynamic binding, you can call only those methods that are present in the current class. If the child overrides the parent method, then the child method is executed, otherwise the parent method will be executed ...
But in the case of interfaces, what happens, I donβt know ... Here is 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();
user1035088
source share