answersLogoWhite

0

What is class cast exception?

Updated: 10/24/2022
User Avatar

Wiki User

11y ago

Best Answer

The class case exception is thrown when an object A of class type B is cast to a class type C where C is neither B nor its subclass.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is class cast exception?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How an exception subclass is created in java explain?

We can create a exception sub class by extending Exception class available in java


Can a class extend exception?

Yes You can. The features of such a class would be similar to what an Exception would have but not exactly as a predefined Java Exception. When you create a user defined exception you extend the java.lang.Exception class which in turn extends the java.lang.Throwable so indirectly you are extending the Throwable class while creating a user defined exception...


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


When do you say an exception is handled?

There is no catch block that names either the class of exception that has been thrown or a class of exception that is a parent class of the one that has been thrown, then the exception is considered to be unhandled, in such condition the execution leaves the method directly as if no try has been executed


How do you throw exception?

using throws class try, catch block we through the exception


What is immediate super class of runtime exception?

If you mean Java's RuntimeException class, its parent class is java.lang.Exception


What is the super class that handles all runtime exceptions?

import java.lang.Exception, the Exception class.


Which is the base class of exception handling in java?

Thorwable


What exception will be thrown when abstract class is instantiated?

None. Because an abstract class cannot be instantiated.


Difference between SQL Exception class and SQL Warning class?

sql exception which provides information on database access errors where as sql warning provides inforamation on database access warnings.


What is the top most class in Exceptions?

All exception types are sub classes of the built-in class Throwable. so at the top most position it is Throwable --- under this comes two branches Exception and Error.


Which package needs to be imported in order to supports exception?

None. The Exception class is part of the java.lang package, which is automatically imported into all Java classes.