Here\'s a test practice question i came across, would appreciate your help in making me understand the concepts
Let Hawk be a subclass of Bird. Suppose some class has tw
At compile time, method invocation for overloaded methods is determined based on the type the method parameters and the compile time (or static) type of the method arguments.
In your case, Third#foo(..)
can take a Hawk
and it can take a Bird
. In your invocation
y.foo(x);
the compile time (or static) type of the argument x
is Bird
, since that's how it's declared, so the Third#foo(Bird)
method will be invoked.