Question: 1.Assume you have a base class Superclass, and class Subclass that extends Superclass. If you have the following code: Superclass c = new Subclass(); will

1.Assume you have a base class Superclass, and class Subclass that extends Superclass. If you have the following code: Superclass c = new Subclass(); will this cause an error? (Assume Subclass has a default constructor). Why or why not?

2. For the classes Superclass and Subclass as described above, which is true:

A Superclass is a Subclass

A Subclass is a Superclass

Both of these

Neither of these.

3. Now assume you have classes Person and Student as defined in class. Assume that you have a Person type variable that references a Student type object. I.e. Person p = new Student(Sally, 18); If the method sayHi() is defined in the Person class and overridden in the student class, which version of the method will be called when I write p.sayHi(), the Persons version or the Students version?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!