Bit shift operators are on the exam for SCJP 1.4, but they were dropped from SCJP 5.
There's one special thing
you should know about bit shift operators, which is mentioned in
section 15.19 of The
Java Language Specification:
If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (�15.22.1) with the mask value 0x1f. The shift distance actually used is therefore always in the range 0 to 31, inclusive.
This means that if you perform the shift operator on a 32-bit integer, only the lower 5 bits of the shift distance are used. So if the shift distance is 32, then it's really 32 & 0x1f = 0.
So, the question you ask is a trick question. Shifting by 32 is the same as shifting by 0 (not shifting at all). Try it out with a small program to see this yourself:
The result is: 3
[ April 04, 2008: Message edited by: Jesper Young ]