Question: JAVA DATA STRUCTURES Suppose that we have classes A, B, C and D. Suppose that B is a subclass of A, that C is a

JAVA DATA STRUCTURES

"Suppose that we have classes A, B, C and D. Suppose that B is a subclass of A, that C is a subclass of B, and D is a subclass of A. Supppose that we make the following declarations:"

A a1 = new A();

A a2 = new C();

D d1 = new D();

For each part below, explain what, if any, errors would be caused by the statement in that part. Be sure to consider both compile time and run time errors.

(a) A a3 = new B();

(b) B b1 = new A();

(c) B b2 = (B) a1;

(d) B b3 = (B) a2;

(e) B b4 = (B) d1;

(f) B b5 = (C)(A) new D();

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!