Professional Documents
Culture Documents
Portfolio On Exception Handling: Submitted by MD - Monirul Islam ID: 221 002 154 Instructor Name Mehrab Zaman Chowdhury
Portfolio On Exception Handling: Submitted by MD - Monirul Islam ID: 221 002 154 Instructor Name Mehrab Zaman Chowdhury
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 :
int num1=input.nextInt();
Please Enter Num1 : 100
System.out.println("Enter Num2 : ");
Please Enter Num 2 : 0
int num2=input.nextInt();
You Must enter integer.
catch(Exception e)
System.out.println("Exception" +e);
}} }}
ANOTHER EXAMPLE
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.