Solved

Consider the Following Code Snippet

Question 55

Multiple Choice

Consider the following code snippet:
ArrayList<Double> arr = new ArrayList<>() ;
String element = arr.get(0) ;
Is there an error in this code?


A) No run-time error or compile-time errors will occur.
B) Yes, a compile-time error will occur because you cannot create an ArrayList of type Double.
C) Yes, a run-time error will occur because a Double value cannot be cast to a String value.
D) Yes, a compile-time error will occur because you cannot assign a Double value to a String variable.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions