We can create a exception sub class by extending Exception class available in java
Chat with our AI personalities
Here is a code snippet illustrating exception handling: try { int a= 3 / 0 ; } catch ( ArithmeticException e ) { System.out.println ("An ArithmeticException has occured"); } finally { // some code }
A class can be a subclass of another class, not of itself.A class can be a subclass of another class, not of itself.A class can be a subclass of another class, not of itself.A class can be a subclass of another class, not of itself.
with new operator
Yes a user defined exception can have any number of methods in it. A user defined exception is nothing but a Java class created for a specific purpose. Just like ordinary Java classes, you can have any number of methods in it...
java exception