This question is primarily
testing your understanding of shift operations. It may help to convert to binary, especially when you're learning.
But since each of these shift operations only shifts one bit, and all 32 bits are filled or set, you don't need to convert the whole number to binary, just the nibble that is changed by the shift.
For example, 0xffffffff is
1111 1111 1111 1111 1111 1111 1111 1111 in binary.
f f f f f f f f
If you shift left one place, (0xffffffff << 1) the result is:
1111 1111 1111 1111 1111 1111 1111 1110
f f f f f f f e
Since the shift is only one position, the right-most bit is the only one that changes. Therefore the rightmost hex-digit (since it represents 4-bits or a nibble) is also the only one that changes in hex format. Once you see that, you can work out the shift operation just by examining the bits that change, converting from hex to binary if that helps.
Shifting right one position is just the same except the leftmost bits are the ones that change. And how they change depends on the shift operator >> or >>>.
So, if you right shift one position and maintain the sign bit 1111 (0xf) remains 1111.
But if you don't maintain the sign bit, 1111 becomes 0111 (0x7).
Arthur's problem is caused by Integer.decode(
String number) which throws a NumberFormatException if the parameter represents a negative number.