Case 2 For Overloading - rahul00773/JavaConcepts GitHub Wiki

class Test{

public void m1(String s){

System.out.println(“String version”);

}

public void m1(Object 0){

System.out.println(“Object version”);

}

}

class T{ public static void main(String[] args){

Test t = new Test();

t.m1(new Object); ///Object Version

t.m1(“rahul”); /// String version

t.m1(null); /// String version

} }

Note: While Resolving overloaded methods compiler will always gives preference for child type argument then compared with parent type argument.