A ClassCastException is thrown when an attempt is made to cast an object, which is not of the appropriate run-time type. It extends from the RuntimeException class. It For example:
Object obj = new Vector();
String s = (String) obj;
Following are the two kinds of constructors for ClassCastException:
ClassCastException()
It will construct a ClassCastException without any detailed message.
ClassCastException(String str)
It will construct a ClassCastException with the specified detailed message.
Responses to “What is the ClassCastException?”