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

Given the code fragment:
List<Integer> list = List.of(11,12,13,12,13);
Which statement causes a compile time error?

Answer options

Correct answer: A

Explanation

The correct answer is A because the method list.get(0) returns an Integer, and trying to assign it directly to a Double variable will cause a compile-time error due to type incompatibility. Options B, C, D, E, and F either correctly convert the Integer to a primitive or use appropriate type assignments without type mismatch.