ClassCastException is the child class of RunTimeException, hence it is an unchecked exception, This exception is automatically Raised by JVM Whenever we are trying to typecast the Parent class object to the child class object then we will get ClassCastException.

public class ClassCastException {
    public static void main(String[] args) {
        Object obj = new Object();
        String str = (String) obj;


Similar Java Tutorials

Leave a Comment