I want some clear idea about Dynamic Polymorphism. When methods in child class are over-ridden and overloaded, I am unable to figure out method calls.
Here is the Parent class:
Parent Class:
public class Parent {
    void print(Parent parent){
        System.out.println("I am parent classes only print method.");
    }
}
Child Class:
public class Child extends Parent {
    void print(Child child) {
        System.out.println("I am child class' child print method.");
    }
    void print(Parent parent) {
        System.out.println("I am Child class' parent print method ");
    }
}
And this is the caller class.
public class Caller {
    public static void main(String[] args) {
        Parent p = new Parent();
        Child c = new Child();
        Parent pc = new Child();
        p.print(p);
        p.print(c);
        p.print(pc);
        c.print(p);
        c.print(c);
        c.print(pc);
        pc.print(p);
        pc.print(c);
        pc.print(pc);
    }
}
I can see the output in console but cannot understand the reason behind the method calls.
 
     
     
     
    