-
Notifications
You must be signed in to change notification settings - Fork 0
Case 2 For Overloading
rahul Kumar edited this page Jul 21, 2020
·
1 revision
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.