Question: 4. [2 points] The following problems all involve three distinct classes, A, B, and C. a. Suppose that the following code compiles and runs

4. [2 points] The following problems all involve three distinct classes, A,

 

4. [2 points] The following problems all involve three distinct classes, A, B, and C. a. Suppose that the following code compiles and runs without any exceptions. What can you say about the relationship between the classes A, B, and C? A x1 = new C(); B x2 = x1; B x3 = (B) x1; B x4 = (C) x1; b. Now suppose the code in part (a) fails to compile, but if we remove the second line it compiles and runs without any exceptions. What can you say about the relationship between the classes A, B, and C? c. Now suppose that the code in (a) fails to compile, and when we remove the second and fourth lines it compiles, but causes a ClassCastException at runtime. What can you say about the relationship between the classes A, B, and C?

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 Programming Questions!