Java - Exceptions - Interview Questions and Answers on ClassCastException

Q1.  When do we get ClassCastException?

Ans. As we only downcast class in the hierarchy, The ClassCastException is thrown to indicate that code has attempted to cast an object to a subclass of which it is not an instance.

Q2.  Invoking start twice on same thread leads to ..

 a. ClassCastException
 b. NullPointerException
 c. InterruptedException
 d. IllegalStateException

Ans. IllegalStateException

Q3. Which interfaces are implemented by ClassCastException?


Q4. Which is the Parent Class of ClassCastException class?