I'm unable to understand how does java "Choosing the Most Specific Method" rule in function overloading works.
I have a class where function overloading is achieved. There are two functions with the same name "show". Once accepts Object type argument and other accepts String type.
I'm calling the function passing null. The method with String type argument gets called.
class Test
{
public void show(String s)
{
System.out.println("hi");
}
public void show(Object o)
{
System.out.println("hello");
}
public static void main(String s[])
{
Test t = new Test();
t.show(null);
}
}
The output will be "Hi". Please help me understand the explanation.