Computer Science, asked by vaishnavivaish211, 7 months ago

What is the output for the below code?
public class Test{
public static void printValue (int i, int j, int k)
{
W
System.out.println("int");
}
1
1
1
1
public static void printValue (byte...b) {
System.out.println("long");
}
1
1
1
.
public static void main(String... args) {
byte b = 9;
printValue (b,b,b);
}
)​

Answers

Answered by reenaagrawal
0

Answer:

Explanation:

Primitive widening uses the smallest method argument possible. (For Example if you pass short value to a method but method with short argument is not available then compiler chooses method with int argument). But in this case compiler will prefer the older style before it chooses the newer style, to keep existing code more robust. var-args method is looser than wider.

Similar questions