This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What is the result of attempting to compile and run the program? Answer is 31,0. Can anyone explain me the exact pen and paper calculation for the same.As I feel the calculation will be pretty hectic, considering that int is 32 bit.
Note: for shifting, only the lowest five bits are used
And in case of long, use lowest six bits.
Joined: May 09, 2005
thanxs a lot for the nice explanation!! Just wanted to confirm one thing, that in case of integers, for shifting lowest 5 bits are used and in case of shifting of long, lowest 6 bits are used? Are these the only two cases?Meaning no other special cases where the no. of bits vary?
Hi, Those are the only possiblities.All other types byte,short,char are promoted to int.
The type promotion is applied to both the operators separately. The resulting type and number of bits shifted depends only on the type of the L.H.S operator. Hope this helps.... -vinu. [ May 19, 2005: Message edited by: vinuharan haran ]