Name : Dnyandeep Badhe
Batch : D2
Roll No. :
304D034
Experiment No. 9
Code :
package company;
public class Exception
{
public static void main(String[] args) {
int a = 4;
int b = 5;
int arr[] = {1,2,3,4,5};
try {
int c = a/b;
System.out.println("c = "+c);
arr[6]= 10;
}catch(ArithmeticException e) {
System.out.println("Arithmatic Exception :");
e.printStackTrace();
}catch(ArrayIndexOutOfBoundsException f) {
System.out.println("Array Index Out of Bounds Exception
:");
f.printStackTrace();
}finally {
System.out.println("Finally Block Executed :");
}
}
}
Output :
c =
0
Array Index Out of Bounds Exception :
java.lang.ArrayIndexOutOfBoundsException: Index 6 out of bounds for
length 5
at company.Exception.main(Exception.java:14) Finally
Block Executed :