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

Given the code fragment:

List list = List.of(11,12,13,12,13);

Which statement causes a compile time error?

    Correct Answer: A

    The statement 'Double d = list.get(0);' causes a compile time error. The get method from the list returns an Integer, and there is no implicit conversion between Integer and Double in Java, leading to a compile-time error. All other options either directly assign the Integer value or use unboxing which is implicitly handled by Java.

Discussion
d7bb0b2Option: A

Only A not compile. Cannot convert Integer To Double directly, (Objetc integer to Object DOuble). ..But can asign Integer to double (primitive). For unboxing (Integer -> int) and then promotion of type int to double.

RP384Option: A

cannot cast from Integer to Double, Double.valueOf() is needed

StavokOption: A

cannot convert from Integer to Double

RoxyFoxyOption: A

Integer cannot be converted to Double

supernhoOption: A

A, cannot cast from Integer to Double

Ankit1010Option: A

A is correct Answer

Leksh_geethOption: A

Answer is Option A