Java OCA OCP Practice Question 2974

Question

Given the invocation "java Main" and:

What is the result?

  • A. c
  • B. c f
  • C. t f
  • D. Compilation fails.
  • E. "c f " followed by an uncaught exception.


C is correct.

Note

It's legal (although not recommended) to catch an Error.

It's also legal for main() to throw an exception.

The trick to this question is that assertions were not enabled, so line 5 is skipped, and no Error is thrown.

If the invocation had been "java -ea Main", then answer E would have been correct.




PreviousNext

Related