class X{
    public void print(X x){System.out.println("xx");}
    public void print(Y y){System.out.println("xy");}
}
class Y extends X{
    public void print(X x){System.out.println("yx");}
    public void print(Y y){System.out.println("yy");}
    public static void main(String[] args){
        X x = new Y();
        x.print(x);
        System.out.println(x.getClass());
    }
}
The output i get is "yx" end I dont understand why, x.getClass() returns "class Y" so shouldn't its call the method where the parameter is Y?
 
     
    