c2 = (C2)((C1)c3); Analyze the statement:

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);


A. c3 is cast into c2 successfully.
B. You will get a runtime error because you cannot cast objects from sibling classes.
C. You will get a runtime error because the Java runtime system cannot perform multiple casting in nested form.
D. The statement is correct.

The correct answer is B


Java

Learn More Multiple Choice Question :