223k views
2 votes
A run-time exception thrown to signal an attempt to cast an object to a class of which it is not an instance is called:

a) ClassCastException
b) NullPointerException
c) ArrayIndexOutOfBoundsException
d) IllegalArgumentException

User Cam Soper
by
7.1k points

1 Answer

6 votes

Final answer:

A run-time exception that signals an illegal cast operation is known as a ClassCastException. This occurs when an object is cast to an incompatible type, resulting in a runtime error.

Step-by-step explanation:

A run-time exception thrown to signal an attempt to cast an object to a class of which it is not an instance is called a ClassCastException. This exception occurs when code attempts to cast an object to a type that it does not inherit from, violating the object's type safety. When the Java Virtual Machine (JVM) detects this invalid cast, a ClassCastException is thrown, indicating that the cast operation is not legally allowed at runtime.

User Ricardo Souza
by
8.1k points