Re: interpretation of null by JVM
Monday, January 30, 2006 05:17 PM
That answer is simple: because the constructor invoked is Test(x) with ONE parameter... Test() has NO parameters, so that is NOT going to be invoked in a million years....(Unless you specify
The real WTF is why it's not displaying "object"... Reason: The JVM is going to look for the best specified parameter. Since String inherits from Object, it's the most specific and gets invoked. If you would have a constructor called Test(Character c) AND Test(String s) the compiler would complain since it cannot determine the most specific declared method (String and Character both inherit from Object, so they are considered the same "level".