Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 62

Given:

What is the output?

    Correct Answer: D

    In Java, when you perform arithmetic operations on primitive types, they are promoted to at least int if they are smaller. In this case, the byte (x) and short (y) are added together, resulting in an int value of 25. Since the class Test does not have a method process that accepts an int, the Java runtime will look for a suitable method which can take an argument that can be assigned from int. The only method that matches this requirement is process(Object v), because an int can be autoboxed to an Integer which is an Object. Thus, the method process(Object v) is called and the output is 'Object value 25'.

Discussion
StavokOption: D

D is correct TESTED

Stavok

The output of the code is D. Object value 25. The code compiles and runs without any errors. In the expression x+y, both operands are promoted to int before the addition is performed, resulting in an int value of 25. Since there is no process method that takes an int argument, the int value is then boxed into an Integer object and passed to the process(Object v) method, which prints Object value 25.

mendjijetOption: D

tested : D x+y => boxed to int and boxed to Integer

OmnisumemOption: D

Tested: D.

tmuralimanoharOption: D

Answer: D x+y becomes int

Mukes877Option: D

D is correct because Object class is base class for every object.

ObaltOption: D

The correct answer is D