1 /*
2 Experiment No: 6
3 Name: Chaitanya Zode
4 Roll No: 66
5 subject: OOP
6
7 Aim:
8 Create a program to handle ArithmeticException,
ArrayIndexOutOfBoundsException, and NumberFormatException. The user
9 enters two numbers, and their division is shown. Handle invalid inputs and division by zero.
10
11 */
12
13 package OOPAssignment6;
14
15 class ExceptionHandling2 {
16 public static void main(String[] args) {
17 int a[] = {1, 2, 3};
18
19 try {
20 int value = a[3]; // This will cause ArrayIndexOutOfBoundsException
21 [Link]("Value at index 3: " + value);
22 }
23 catch (ArrayIndexOutOfBoundsException e) {
24 [Link]("Array Index Out of Bounds Exception caught.");
25 }
26 }
27 }
28
29
30 /*
31 ------------------------- OUTPUT --------------------------------32
33 Array Index Out of Bounds Exception caught.
34
35 */