Solved

Consider the Following Code Snippet

Question 44

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 executing the following code?
Box<String> box = new Box<>() ;
...
box.insert("blue Box") ;
String b = (String) box.getData() ;


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

Correct Answer:

verifed

Verified

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

Related Questions