Given:



What is the result?

A.

Invalid Divisor
Divisor Changed
Successful Division 30

B.

Invalid Divisor
Successful Division 30

C.

Invalid Divisor
Exception in thread "main" java.lang.ArithmeticException: / by zero
at test.Teagle.main(Teagle.java:14)

D.

Invalid Divisor
Exception in thread "main" java.lang.ArithmeticException: / by zero
at test.Teagle.main(Teagle.java:14)
Successful Division 1

題解

第6行「aw」變數的值是10除以2的餘數,也就是0。因此第7行把值為0的「aw」變數作為除數,會拋出ArithmeticException,然後在第8行被catch接到。

接著程式執行到第14行,依然會拋出ArithmeticException,但是這個ArithmeticException會直接由main方法往外拋出給執行緒。