Hi,
I am preparing for my
SCJP exam and when I was looking through JavaRanch's previously posted questions, the following problem occured to me.
Consider the following code.
The above program compiles and runs fine. But due to the widening conversions, both the methods are valid. In such a case, I would have expected the first occuring method in the program to be called.
However, the compiler seems to be kind of smart and calls the method that has the closest widening conversion. I verified this with another function with signature
and it picked that method.
Can anyone explain the reasoning behind this?