The compiler will try to match with the most specific parameter, which in this case is NullPointerException
. You can see more info in the Java Language Specification, section 15.12.2.5. Choosing the Most Specific Method
:
If more than one member method is both accessible and applicable to a
method invocation, it is necessary to choose one to provide the
descriptor for the run-time method dispatch. The Java programming
language uses the rule that the most specific method is chosen.
The informal intuition is that one method is more specific than
another if any invocation handled by the first method could be passed
on to the other one without a compile-time type error.
[...]