← Back to Exceptions
Question 762
The finally Block Always Runs
The finally Block Always Runs
Read an integer and printParsed: <n>. If the input is not a number, catch theFormatExceptionand printBad input. Add afinallyblock that always printsDone, whether or not an exception happened. Use top-level statements withtry/catch/finally. Input7prints the output shown in Expected Output. Inputxyzprints: Bad input Done
Expected Output:
Parsed: 7 Done
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Exceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.