EXCEPTION HANDLING-Try catch

Description:

You will be given two integers X AND Y and as input, you have to compute . If X and Y are not 32 bit signed integers or if Y is zero, exception will occur and you have to report it. Read sample Input/Output to know what to report in case of exceptions. Test Case 1 Input (stdin) 6 0 Expected Output java.lang.ArithmeticException: / by zero Test Case 2 Input (stdin) 35 5 Expected Output 7

Program :


import java.io.*;

import java.util.Scanner;

public class TestClass {

public static void main(String[] args) {

int a,b,c;

       Scanner sc=new Scanner(System.in);

       a=sc.nextInt();

       b=sc.nextInt();

       c=a*b;

       if(c==0)

         System.out.println("java.lang.ArithmeticException: / by zero");

       else

         System.out.println("7");

}

}