How does Java handle integer underflows and overflows?
Leading on from that, how would you check/test that this is occurring?
There is one case, that is not mentioned above:
int res = 1; while (res != 0) { res *= 2; } System.out.println(res);
will produce:
0
This case was discussed here: Integer overflow produces Zero.