← Back to Exceptions
Question 755
Identify The Exception Type
Identify The Exception Type
Read an integern. Ifn == 0, throw aDivideByZeroException; ifn < 0, throw anArgumentException; otherwise printValue: <n>. Use a singlecatch (Exception ex)that catches any of them and printsCaught: <ex.GetType().Name>. Use top-level statements. Input5prints: Value: 5 Input0prints: Caught: DivideByZeroException Input-1prints: Caught: ArgumentException
Expected Output:
Value: 5= newline. The output ends with a newline — print one after the last line.
Hints4 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.