OCA Java SE 8 Exception - OCA Mock Question Exception 2
Question
What will happen if you add the statement System.out.println(1 / 0); to a working main() method?
- It will not compile.
- It will not run.
- It will run and throw an ArithmeticException.
- It will run and throw an IllegalArgumentException.
- None of the above.
Answer
Note
At runtime, Arithmetic checking is before passing it to the print() method,
so an ArithmeticException object is raised.