Solved

Consider the Following Code Snippet: ArrayList<Double> Arr = New ArrayList<Double>();

Question 40

Multiple Choice

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


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

Correct Answer:

verifed

Verified

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

Related Questions