0

Our java code will not compile when we do not throw exception when we use some logic where exception might occur (such as we have to either enclose the code in try-catch or use throws while working with files on system.) So in the same way why java developer did not consider Run time exceptions as checked exception?

We know that ArrayIndexOutOfBoundException can occur while using array. So why it was not included as checked exception, and is called an unchecked exception?

  • According to java document http://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html..If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception. – saurav Jan 22 '16 at 10:13
  • If `ArrayIndexOutOfBoundException` was a checked exception each and every method using arrays would have to catch it or to declare it in the throws clause. – Henry Jan 22 '16 at 10:14

0 Answers0