Solved

Consider the Following Code Snippet

Question 75

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 = (Object) box.getData() ;


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

Correct Answer:

verifed

Verified

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

Related Questions