Write a program to use exception concept in Java

Code:

class Exe
{
public static void main(String ar[])
 {
 int a=10,b=0,c;
 try
  {
   c=a/b;
   System.out.println("Division is "+c);
  }
 catch(Exception e)
  {
   System.out.println("Error");
  }
   c=a+b;
  System.out.println("Addition is"+c);
 }


Output:


Comments