The following program accepts the input of an integer from the keyboard and perf
ID: 3596410 • Letter: T
Question
The following program accepts the input of an integer from the keyboard and performs subtraction and multiplication operations using the Java Math.subtractExact and Math.multiplyExact functions. It has a try/catch sequence designed to catch exceptions thrown for non-numeric keyboard input, subtraction overflow, and multiplication overflow. However, it will not compile. Explain why and what must be done to correct the error.
Explanation / Answer
The program wasn't able to compile because ArithmeticException have been caught twice in the catch. You have to comment either one of ArithmeticException for successful compilation and execution of the code.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.