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?

  1. It will not compile.
  2. It will not run.
  3. It will run and throw an ArithmeticException.
  4. It will run and throw an IllegalArgumentException.
  5. None of the above.




Answer



C.

Note

At runtime, Arithmetic checking is before passing it to the print() method, so an ArithmeticException object is raised.