I was asked the output of this question in an interview, though I answered correctly I am not able to figure out the exact reason
class Main{
void hello(Object obj)
{
System.out.println("i am object");
}
void hello(String str)
{
System.out.println("i am String");
}
public static void main(String[] args)
{
Main m = new Main();
m.hello(null);
}
}
Output
i am String