Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Java | Exception Handling | Question 3

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Output of following Java program?




class Main {
   public static void main(String args[]) {
      int x = 0;
      int y = 10;
      int z = y/x;
  }
}


(A) Compiler Error
(B) Compiles and runs fine
(C) Compiles fine but throws ArithmeticException exception


Answer: (C)

Explanation: ArithmeticException is an unchecked exception, i.e., not checked by the compiler. So the program compiles fine. See following for more details.

Checked vs Unchecked Exceptions in Java

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads