Open In App
Related Articles

Java | Exception Handling | Question 3

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads