1// Aim: Program to perform Exception Handling operations (Arithmetic and ArrayIndexOutOfBoundsException).
2public class ArithmeticAndArrayindexoutofboundsexception {
3 public static void main(String[] args) {
4 try {
5 int result = 10 / 0;
6 System.out.println("Result: " + result);
7 } catch (ArithmeticException e) {
8 System.out.println("Caught an ArithmeticException: " + e.getMessage());
9 }
10 try{
11 int[] arr = new int[5];
12 arr[5] = 10;
13 }
14 catch (ArrayIndexOutOfBoundsException e) {
15 System.out.println("Caught an ArrayIndexOutOfBoundsException: " + e.getMessage());
16 } finally {
17 System.out.println("This is the finally block. It always executes.");
18 }
19 }
20}