When you declare a variable as string with out intializing it, it will have "null" as a value in it.So when you pass null as a value string constructor will get invoked.Have you got cleared??
Joined: Feb 02, 2006
Thanks for the reply Ganesh but still its unclear. You are saying that When we declare a String like String s then we get a null String object Same should be the case when i declare Object o it should also give a null object.
Java would choose the closest match. That is, let say you have a String and StringBuffer constructor/method. Now both are not related to each other apart from the fact that both have a common parent/grandparent Object. So in this case when you pass null compiler would not be able to decide which invocation of the method/constructor is asked for. But in case you have a hierarchy, the one who is closest to the reference type is chosen.