Simple java program to show how exception works
public class exception{public static void main(String[] args){try{int a = 10;int b = 10/0;}catch(ArithmeticException e){System.out.println(“Exception Caught ” + e);}}}
The output will be like you expect
Exception Caught java.lang.ArithmeticException: / by zero