Sumit Patil wrote:Actually i want to know how the output comes as shown when i pass a 'null'
Because any object reference can be "null". So you are allowed to pass null where a reference of any object is expected.
Compiler matches the most specific one hence the Object type argument and not the Object type argument. Is this answer your question?
Actually when you pass null to a overloaded method or a overloaded Constructor, the most subtype in the inheritance hierarchy parameter method is chosen and run. As you can see Object extends from Object, that is the most subtype in the current scenario(can add a constructor having String parameter which will will run). But this is valid only if the parameters fall in the same hierarchy. If some other parameter comes then it will be an error(if String is changed to String).
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api