Well the question asked for
runtime exception.
If you tried each of these,
you should find that options [2], [4], [5] will result in
compile time exceptions . Option [1] compiles and runs. Which only leaves option [3] as your choice.
[1] runs because y, an instance of B,
isaA.
[2] x is not a C, so no implicit conversion occurs. You have to explicitly cast it
[3] similar to [2], x is not a B, however an explicit cast is used in this case, so this will compile. Although because x is actually not a B, a ClassCastException will be thrown at runtime
[4] classes B and C both extend A, which means that they are sibling classes. Conversion between them is disallowed by the compiler
[5] Obviously, y is of type B, the statement is trying to assign an type of A to a type of B, which means the compiler will complain abou it.
HTH
