Write a Java program that throws an exception and catch it using a try-catch block.

Source Code:

public class TryCatchExample {
public static void main(String[] args) {
try {
int a = 10 / 0;
} catch (ArithmeticException e) {
System.out.println(“Exception caught successfully”);
}
}
}

Output: