Java | Exception Handling | Question 3
Output of following Java program?
class Main { public static void main(String args[]) { int x = 0; int y = 10; int z = y/x; } } |
chevron_right
filter_none
(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
Recommended Posts:
- Java | Exception Handling | Question 4
- Java | Exception Handling | Question 1
- Java | Exception Handling | Question 8
- Java | Exception Handling | Question 8
- Java | Exception Handling | Question 2
- Java | Exception Handling | Question 7
- Java | Exception Handling | Question 6
- Nested try blocks in Exception Handling in Java
- Exception Handling with Method Overriding in Java
- Output of Java program | Set 12(Exception Handling)
- C++ | Exception Handling | Question 12
- C++ | Exception Handling | Question 2
- C++ | Exception Handling | Question 8
- C++ | Exception Handling | Question 9
- C++ | Exception Handling | Question 10



