Given:
What is the outcome?
The cast at line n1 succeeds because the object is a C, and C extends A. The cast at line n2 throws ClassCastException because the runtime object is a C, not a B; execution therefore does not reach either test() invocation.
C
A
ClassCastException
B
test()
Community Discussion