Professional Documents
Culture Documents
Port
Port
EXCEPTION HANDLING
SUBMITTED BY
INSTRUCTOR NAME
MD.MONIRUL ISLAM
MEHRAB ZAMAN CHOWDHURY
ID : 221 002 154
EXCEPTION
An Exception is a run time error.
Example
int x=10;
int y=0;
ArithmeticException
int x=10;
int y=0;
NullPointException
String name=null;
System.out.println(name.charAt(0));
// NullPointException
StringIndexOutOfBoundsException
String name=”OOP”;
System.out.println(name.charAt(5));
// StringIndexOutOfBoundsException
NumberFormatException
int name=”GUB”;
// NumberFormatException
FileNotFoundException
// FileNotFoundException
ArrayIndexOutOfBoundsException
A [10] = 100;
// ArrayIndexOutOfBoundsException
EXCEPTION HANDLING
The Exception handling in one of the powerful mechanisms to handle the runtime errors.
try {
finally {
Write a Program that will safely divide one integer by another integer. See the sample output
below. Sample execution :
class Example{
try{
arr[10]=10/5;
catch(ArithmeticException e){
catch(ArrayIndexOutOfBoundsException e){
catch(Exception e){
OUTPUT
In conclusion, exception handling is a crucial aspect of Java programming that allows developers to
handle runtime errors in a controlled and graceful manner. A well-structured and effective
exception handling portfolio can demonstrate your expertise in this area and showcase your ability
to handle exceptions, improve application stability, and ensure reliable code execution.