Question 1
Analyze the following code:
Circle c = new Circle (5);
Cylinder c = cy;
◦ The code has a runtime error.
◦ The code has a compile error.
◦ The code is fine.
Question 2
Given the following classes and their objects:
class C1 {};
class C2 extends C1 {};
class C3 extends C1 {};
C2 c2 = new C2();
C3 c3 = new C3();
Analyze the following statement:
c2 = (C2)((C1)c3);
◦ c3 is cast into c2 successfully.
◦ You will get a runtime error because the Java runtime system cannot perform multiple casting in nested form.
◦ You will get a runtime error because you cannot cast objects from sibling classes.
◦ The statement is correct.