Exception Handling
Exception Handling
on
“Exception Handling in
Java”
Presented By,
Harshitha K. S. MCA
06/02/2025 1
Difference between Exception & Error
Exception Error
Exceptions are classified as checked and Errors are only unchecked type in java
unchecked type
06/02/2025 2
Exception Handling
• What is Exception?
the execution of program i.e. at run time, that disrupts the normal flow of the program’s
instruction”.
06/02/2025 3
Exception Handling…
“ Exception Handling is a mechanism to handle Run Time Errors”.
or
“The Exception Handling in Java is one of the powerful mechanism to
handle the runtime errors so that normal flow of the application can be
maintained”.
Advantage:
Maintain the normal flow of the program
06/02/2025 4
Exception Handling…
06/02/2025 5
Exception Handling…
try block
• Whenever we write a statement and if that statement is error
suspecting or code is risky then we put that code/statement inside the
try block.
06/02/2025 6
Exception Handling…
Catch :
Note:
catch block will not be executed if there is no exception inside
the block.
06/02/2025 7
Exception Handling…
• Java Exception Keywords
8
06/02/2025
Exception Handling…
Finally:
• Finally block is a Realtime block and the main purpose of this finally
block is to handle the resource.
06/02/2025 9
Flow chat for Finally
Start
yes
Except
ion
No
Execute catch
block
Finally
END
06/02/2025 10
Exception Handling…
• Java Exception Keywords
11
06/02/2025
Exception Handling…
throw
What is throw block?
06/02/2025 12
Exception Handling…
throws
What is throws ?
throws keyword is used when we doesn’t want to handle the
exception and try to send the exception to the JVM.
06/02/2025 13
Exception Handling…
• Java Exception Keywords
06/02/2025 14
Exception Handling…
There are mainly two types of exceptions: checked and unchecked. Here, an error
is considered as the unchecked exception. there are three types of exceptions:
1. Checked Exception
2. Unchecked Exception
3. Error
15
06/02/2025
Types of Exceptions:
06/02/2025 16
Exception Handling…
• Java Exception Keywords
06/02/2025
17
Exception Handling…
• Java Exception Keywords
18
06/02/2025
06/02/2025 19
Thank you
06/02/2025 20