Solved

Consider the Following Code Snippet

Question 3

Multiple Choice

Consider the following code snippet:
public class Box<E>
{
private E data;
public Box() { ...}
public void insert(E value) { ...}
public E getData() { ...}
}
What will result from the following code?
Box<String> box = new Box<>() ;
...
box.insert("blue Box") ;
Double myDouble = (Double) box.getData() ;


A) compiler error
B) correct, but unnecessary cast
C) correct, with necessary cast
D) run-time error

Correct Answer:

verifed

Verified

Related Questions