package polymorphism;
/*
* @author Rahul Tripathi
*/
public class OverLoadingTest {
/**
* @param args
* @return
*/
static void display(String s){
System.out.println("Print String");
}
static void display(Object s){
System.out.println("Print Object");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
OverLoadingTest.display(null);
}
}
Output:
Print String
IN above program
when overload same method display(String s )
and display(Object o)
,when pass null
in method from main method why display(String s )
is called only. Why not called display(Object o)
?