75 How many Keywords are We using in Exception Handling in Java?

Keywords Used in Exception Handling:
1) try
2) catch
3) finally
4) throws
5) throw
6) assert


Code:

import java.util.Scanner;
class Test
{
public static void main( String args[] )
{
try
  {
System.out.println( " Main Methods Starts " );
Scanner scan = new Scanner( System.in );

System.out.println( "\n\n Enter two number: " );
int a = scan.nextInt();
int b = scan.nextInt();
 
int c = a/b;
System.out.println( " C: " + c);

}
catch( ArithmeticException e  )
// ArithmeticException e = new ArithmeticException(" /by zero ");
{
System.out.println(" Don't enter 0 as Denominator "+e.getMessage() );
}
finally
{
System.out.println( " Main Methods Ends " );
}
}
}


Output:

Previous
Next Post »