Page 948 - AP Computer Science A, 7th edition
P. 948

9. (D) The error that occurs is a run-time error caused by an attempt to divide by zero (ArithmeticException). Don’t be fooled by choice C. Simply reading an expression 8/0 from the input file won’t cause the error. Note that if the operands were of type double, the correct answer would be E. In this case, dividing by zero does not cause an exception; it gives an answer of Infinity. Only on inspecting the output would it be clear that something was wrong.


































































































   946   947   948   949   950