Presentation
on
“Exception Handling in
Java”
Presented By,
Harshitha K. S. MCA
06/02/2025 1
Difference between Exception & Error
Exception Error
Exceptions are not caused by our
Exception is caused by our program
program
Exceptions are recoverable Errors are not recoverable
Exceptions are classified as checked and Errors are only unchecked type in java
unchecked type
06/02/2025 2
Exception Handling
• What is Exception?
“ An Exception is an unwanted /unexpected/abnormal Situation which occurs during
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…
5Keywords Used for Exception
Handling
• Try
• Catch
• Finally
• throw
• throws
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.
• Try is a block that contains only risky code.
06/02/2025 6
Exception Handling…
Catch :
What is catch block?
• The main purpose of the catch is to handle the exception which
are throws by try block
• It is used to handle the exception.
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:
What is finally block?
• Finally block is a Realtime block and the main purpose of this finally
block is to handle the resource.
• It is always executed whether exception is caused or not.
06/02/2025 9
Flow chat for Finally
Start
yes
Except
ion
No
Ignore the rest code
of try block Ignore catch block
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?
throw keyword is used to throw the user defined or customized
exception object to the JVM explicitly .
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…
Types of Java Exceptions
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:
checked Exceptions: Compile time exception
Unchecked Exceptions: Run Time Exceptions
Run Time Exceptions are:-
1. Arithmetic Exceptions
2. Number Format Exceptions
3. Array Index Out of Bounds Exception
4. Null Point 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