โ Back to Exceptions
Question 662
Overflow On Byte Cast
Overflow On Byte Cast
Read an integernand convert it to abyteusingchecked((byte)n), then printByte: <b>. Abyteholds0to255; in acheckedcast, a value outside that range throws anOverflowException. Catch it and printToo large for byte. Use top-level statements. Input200prints: Byte: 200 Input300prints: Too large for byte
Expected Output:
Byte: 200
Topics:
Exceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.