Java OCA OCP Practice Question 225

Question

While testing some code that you are developing, you notice that an ArrayIndexOutOfBoundsException is thrown. What is the appropriate reaction?

  • A. Enclose the offending code in a try block, with a catch block for ArrayIndexOutOfBoundsException that does nothing.
  • B. Enclose the offending code in a try block, with a catch block for ArrayIndexOutOfBoundsException that prints out a descriptive message.
  • C. Declare that the method that contains the offending code throws ArrayIndexOutOfBoundsException.
  • D. None of the above.


D.

Note

Since ArrayIndexOutOfBoundsException is a runtime exception, it indicates a faulty algorithm that should not be released. The only appropriate response is to find and fix the bug.




PreviousNext

Related