answersLogoWhite

0

Can a class extend exception

Updated: 8/10/2023
User Avatar

Wiki User

13y ago

Best Answer

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...

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Exception class in Java is not final and many packages typically extend Exception to customize their own exception handling.

RuntimeException is likewise a non-final public class that can be extended.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can a class extend 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


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)


What is class cast exception?

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.


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.


What class can you extend to create a simple class that provides remote methods using RMI in java?

Remote


Why would you make a class final in java?

You would make a class Final in Java if you do not want anybody to inherit the features of your class. If you declare a class as Final, then no other class can extend this class. Example: public final class X { .... } public class Y extends X { .... } Here Y cannot extend X because X is final and this code would not work.


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.