This is called static
polymorphism where the compiler is responsible for making the appropriate method call instead of the runtime system also known as method overloading.
In your first call to the method null is enclosed in double quotes
("null") which is a string literal therefore the method that accepts a string is invoked by the compiler.
In your second call the class only contains one method where the formal parameter is an Integer object reference... since all object references can point to nothing
(null) the compiler invoked the method.
If you call the method passing in
null in your first class with more than one method then the call becomes ambiguous and the compiler can't resolve which method to invoke therefore is will result in a compilation error.