above code compiles fine.does it mean that "null" is considered to be an object?
Ernest Friedman-Hill wrote:"null" is a reference to "no object" -- it is not an object, but just a "pointer" that points to nothing. It is automatically assumes any reference type, so that null means "no String", or "no Object", or "no JFrame", or whatever.
When a method is invoked,the number of actual arguments (and any explicit type arguments) and the compile-time types of the arguments are used, at compile time, to determine the signature of the method that will be invoked...
15.12.2 Compile-Time Step 2: Determine Method Signature
The second step searches the type determined in the previous step for member methods. This step uses the name of the method and the types of the argument expressions to locate methods that are both accessible and applicable, that is, declarations that can be correctly invoked on the given arguments. There may be more than one such method, in which case the most specific one is chosen. The descriptor (signature plus return type) of the most specific method is one used at run time to perform the method dispatch.