Java SE 11 Developer (1Z0-819) — Question 63

Given the code fragment:

Integer i = 11;

Which two statements compile? (Choose two.)

Answer options

Correct answer: B, E

Explanation

Option B is correct because Double.valueOf(i) correctly converts the Integer to a Double. Option E is also correct since assigning an Integer to a primitive double is permitted due to auto-unboxing. Options A, C, and D are incorrect as they involve invalid type casting or incorrect use of methods.