Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/varargs-vs-widening-vs-autoboxing-in-java
Question 127 / 297:  What is the result of compiling and running the following code?
public class Tester {

static void call(Long x, Long y) {

System.out.print("Long x, Long y");

}

static void call(int... x) {

System.out.print("int... x");

}

public static void main(String[] args) {

int val = 3;

call(val, val);

}

}

A  Long x, Long y
B  int... x
C  Compilation error
D  An exception is thrown at run time
<< First < Previous Next > Last >>
Explanation:

Var-args is always chosen last, but since you cannot widen then autobox (cannot widen from int to long then autobox to Long), int... x is printed

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
George Turner
Start Quiz
Carly Allen
Start Quiz
Jesenia Wofford
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>