Question: Given the following class and reference declarations, what can be said about the statement y = (Sub) x? Select the one correct answer. (a) It
Given the following class and reference declarations, what can be said about the statement y = (Sub) x?

Select the one correct answer.
(a) It is illegal at compile time.
(b) It is legal at compile time, but might be illegal at runtime.
(c) It is definitely legal at runtime, but the cast operator (Sub) is not strictly needed.
(d) It is definitely legal at runtime, and the cast operator (Sub) is needed.
// Class declarations: class Super {} class Sub extends Super {} // Reference declarations: Super x = null; Sub y = null;
Step by Step Solution
3.54 Rating (161 Votes )
There are 3 Steps involved in it
b The compiler will allow the statement as ... View full answer
Get step-by-step solutions from verified subject matter experts
