java.lang.ArithmeticException in java - Divide number by zero

What is hierarchy of java.lang.ArithmeticException?


ArithmeticException is Checked (compile time exceptions) and UnChecked (RuntimeExceptions) in java ?

java.lang.ArithmeticException is a Runtime Exception in java.

What is ArithmeticException in java?

java.lang.ArithmeticException is thrown when some exceptional arithmetic condition occurs in java.

Scenarios where ArithmeticException may be thrown in java >

Dividing Integer number by zero will throw java.lang.ArithmeticException in java.

public class DivideByZero {
public static void main(String[] args) {
     try {
          int x = 1;
          x = x / 0;
     } catch (ArithmeticException e) {

output of above program will be
java.lang.ArithmeticException: / by zero
at DivideByZero.main(

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
//start paginationJs //end paginationJs