Professional Documents
Culture Documents
Exception Handling
2. catch
3. throw
4. throws
5. finally
syntax
throw exception;
throws
• Error and its subclasses represent abnormal situations that happen in the
JVM. Most Errors happen infrequently and should not be caught by
applications—it’s usually not possible for applications to recover from Errors
Used by Java run time system
Exception Hierarchy handles the error
Creates exception and hands it
Object to the run time system name
and description, current state
of the program
Throwable Creating the exception object
and handling it to the run time
system is called throwing the
Errors exception
Exceptions
Unchecked
Assertion Errors
Exceptions
Checked vs Unchecked
Checked Unchecked
1. Checked by the compiler at 1. Occurs at runtime. Also
compile time called as runtime exceptions.
2. Cannot be ignored, the Built in exceptions in java
programmer should handle 2. Ignored at the compile time
these exceptions Example:Divide by zero
Example: IO exceptions
JAVA Exception Hierarchy