What will the program print when compiled and run?.
public class Main { public static void main(String[] args) { callType(10);//from w w w .j a v a 2s . co m } private static void callType(Number num){ System.out.println("Number passed"); } private static void callType(Object obj){ System.out.println("Object passed"); } }
Select the one correct answer.
callType()
method is ambiguous.(b)
The method with the most specific signature is chosen.
In this case the int argument 10 is converted to an Integer which is passed to the Number formal parameter, as type Number is more specific than Object.