1. WAP for handling DivideByZeroException.
public class DivideByZeroExceptionHandling {
public static void main(String[] args) {
try {
int a = 10;
int b = 0;
int result = a / b;
[Link]("Result: " + result);
} catch (ArithmeticException e) {
[Link]("Error: Cannot divide by zero.");
OUTPUT :
C:\>cd DILLIBABU
C:\DILLIBABU>javac [Link]
C:\DILLIBABU>java DivideByZeroExceptionHandling
Error: Cannot divide by zero.
C:\DILLIBABU>