Basic Arithmetic Exception Example in Java


Here is the simple program for printing basic example of Arithmeic Exception in Java.

Source Code

import java.io.*;
import java.util.*;
class arith_exp
{
  public static void main(String args[])
  {
   int a,b,c;
   a=10;
   b=0;
   try
   {
   	c=a/b;
   	System.out.println("\nAnswer : "+c);
   }
   catch(Exception e)
   {
   	System.out.println(e);
   }
   finally
   {
    System.out.println("process completed");
   }
  }
}
To download raw file Click Here

Output

java.lang.ArithmeticException: / by zero
process completed


Learn All in Tamil © Designed & Developed By Tutor Joes