Author Topic:   Please check this qstn from Khalid Mock Exam.
maha anna
posted April 04, 2000 07:21 PM             
This is from Mr.Khalid's Mock Exam. I checked the answer of this qstn by cheating, just answering 1 qstn at a time and finishing the test and saw the result.

Which statements are true concerning the effect of the >> and >>> operators?

1) For non-negative values of left operand >> and >>> will have same result
2) The result of -1 >> 1 is 0
3) The result of -1 >>> 1 is -1
4) The value returned by >>> will not be -ve as long as the right operand
is equal to or greater than 1
5) When using >> operator the left most bit of the result will always be same as of the left operand

Ans given was 1) 4) 5)

I think ans shd be 1) 5) because -100>>>32 will be -100 right?
We see the last 5/6 bits of the right operand depending on the left is int/long
So we can not generalize the statement like this in ans 4)

Any input welcome.
maha anna

[This message has been edited by maha anna (edited April 04, 2000).]

Jim Yingst
posted April 04, 2000 08:13 PM             
You're right - but see Mughal & Rasmussen's errata.

posted April 05, 2000 01:40 AM             
>>> 32 will result in shifting the bit by 0 positions.

maha anna
posted April 05, 2000 09:13 AM             
Thanks. This qstn is put in the ErrataPage with the corrected version of the answer 4)
maha anna