17)Write a program to demonstrate the usage of try and associated keywords. Introduce bugs into the program to raise exceptions and then catch and process them.

PHOTO EMBED

Mon Jul 08 2024 06:14:04 GMT+0000 (Coordinated Universal Time)

Saved by @varuntej #java

public class ExceptionExample {
    public static void main(String[] args) {
        int n = 26;
        try {
            int m = n / 0;
        } catch (ArithmeticException e) {
            System.out.println("Exception caught: " + e);
        } finally {
            System.out.println("Any number cannot be divided by zero");
        }
    }
}
content_copyCOPY