When there is a function call whose argument matches super classes and also subclasses, JVM try to call the most specific one. Here in case which is "class Sub".
But if you define another version of the same function like the following...
then call to
will result an compiler error. Because both String and (Sub or Super) can hold the null value but String or (Sub and Super) don't has any subclass superclass relation. So JVM cannot determine which function to call, results an ambiguity.