Solved

Consider the Following Code Snippet

Question 43

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<String>() ;
) . .
Box) insert("blue Box") ;
String b = (String) box.getData() ;


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

Correct Answer:

verifed

Verified

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

Related Questions