Given the following class and reference declarations, what can be said about the statement y = (Sub) x?.
// Class declarations: class Super {} class Sub extends Super {} // Reference declarations: Super x; Sub y;
Select the one correct answer.
(b)
The statement would be legal at compile time, since the reference x might actually refer to an object of the type Sub.
The cast tells the compiler to go ahead and allow the assignment.
At runtime, the reference x may turn out to denote an object of the type Super instead.
If this happens, the assignment will be aborted and a ClassCastException will be thrown.