First a correction: these PowerSupply() things are not methods but constructors.
Ok, in main we do new PowerSupply(null) so one of PowerSupply(String) or PowerSupply(Object) will be used to construct the instance. The Java Language Specification specifies that the most specific one will be used. String is derived from Object, so it is the most specific of the two. There is no other possibility so PowerSupply(String) is used.
Something to try: add the following constructor and compile again.
Do you understand why the compilation fails? [ June 10, 2004: Message edited by: Barry Gaunt ]
I made the following related observations based on various mock tests.
Let us assume methods are overloaded- say we have methods method(char), method(int), method(float), method(double), method(Object), method(String), method(Integer). If an anonymous primitive / object is passed the method invoked will be based on the anonymous primitive / object type. If the primitive / object was not anonymous the method invoked would be based on the primitive�s variable type or object�s reference type. If the argument is an anonymous null and there are multiple overloaded methods that take reference arguments the compiler will complain about the ambiguity since there are multiple overloaded methods that take reference arguments but there are two inheritence heirachies String->Object & Integer->Object. If however the methods were method(char), method(int), method(float), method(double), method(Object), method(String) and the argument is an anonymous null then since there are multiple overloaded methods that take reference arguments but there is only one inheritence heirachy it will take the highest type here -String.
If there is no corresponding methods an attempt for widening conversion or upcasting will be attempted as with polymorphism. While doing the widening or upcasting when the argument is a primitive the nearest (narrowest -thus if argument is a long and methods are method(char), method(int), method(float), method(double), method(Object), method(String) then method(float) will be used) primitive will be used and when the argument is a reference the farthest(widest-similar to discussion on anonymous nulls) type will be used. On the other hand the designers of the Java programming language felt that implicit narrowing conversions of method and constructor arguments would add unnecessary complexities to the process of resolving overloaded method calls. So implicit narrowing is never attempted during overloading. Note: implicit narrowing is attempted during assignments and compound assignments. Otherwise the binding is compile time binding and not dynamic binding as with polymorphism