Explain what happens if an exception occurs half-way through executing a block of code that is surrounded
Fantastic news! We've Found the answer you've been seeking!
Question:
- Explain what happens if an exception occurs half-way through executing a block of code that is surrounded by a 'try' block that is followed by severalcatch() blocks that have their own code blocks
- Complete the code for a driver classTwoErrors to demonstrate your explanation in (a).
The main method should :
- Declare three integers and an integer array with three elements.
- have atry{ } block which
- shows a division of 0, using your integer variables, which will (obviously) throw anArithmeticException
- assigns an array element to an integer, which will cause anArrayIndexOutOfBoundsException
- have the respectivecatch() blocks, as well as acatch()block that handles generic Exceptions.
- Code simple messages or use theprintStackTrace orgetMessage options in thecatch() blocks.
- have afinally block that shuts your system down because there is an error.
Posted Date: