Question: Suppose the class Sub extends the class Sandwich. Which of the following assignments are legal? Sandwich x = new Sandwich(); Sub y = new Sub();
Suppose the class Sub extends the class Sandwich. Which of the following assignments are legal?
Sandwich x = new Sandwich();
Sub y = new Sub();
a. x = y;
b. y = x;
c. y = new Sandwich();
d. x = new Sub();
Step by Step Solution
3.43 Rating (162 Votes )
There are 3 Steps involved in it
a x y is legal because Sub is a subclass of Sandwich so an object ... View full answer
Get step-by-step solutions from verified subject matter experts
