What will be the output?

A.

SpecialException: Thrown at end of doSomething() method

B.

Error in thread "main" java.lang.ArrayIndexOutOfBoundsError

C.

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at ExceptionTest.doSomething(ExceptionTest.java:13)
at ExceptionTest.main(ExceptionTest.java:4)

D.

SpecialException: Thrown at end of doSomething() method
at ExceptionTest.doSomethingElse(ExceptionTest.java:16)
at ExceptionTest.doSomething(ExceptionTest.java:13)
at ExceptionTest.main(ExceptionTest.java:4)

題解

程式會在第19行拋出ArrayIndexOutOfBoundsException,再從main方法繼續向外拋出,導致執行緒產生例外中斷。因為ArrayIndexOutOfBoundsException並不是SpecialException的子類別,因此無法被第13行的catch接住。