Java Integer Overflow
Develop code to cast primitive values to different primitive types in arithmetic expressions and determine the value that is produced as a result.
What is printed as a result of executing this code segment?
int max = Integer.MAX_VALUE;
int result = max + 1;
System.out.println(result);
A
2147483648
B
An ArithmeticException is thrown
C
-2147483648
D
2147483647
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | jeonsaw1723 | 2 | 2 | 0m 35s | 165 |
| #2 | thuyjerry | 1 | 1 | 0m 00s | 100 |
| #3 | kaisuki | 1 | 4 | 0m 00s | 70 |
| #4 | sailajavadlamani33 | 1 | 4 | 0m 00s | 70 |
| #5 | sgarv2513 | 1 | 4 | 0m 00s | 70 |
| #6 | 29AmeliaC | 1 | 1 | 0m 30s | 70 |
| #7 | patrickmeijer009 | 1 | 4 | 0m 50s | 20 |
| #8 | richa.tuli | 1 | 1 | 1m 50s | -10 |
| #9 | psak12 | 2 | 6 | 4m 53s | -133 |
| #10 | y.seong2027 | 1 | 3 | 5m 02s | -222 |
APFIVE