Hi Vinita, This one is about primitive types. The rule is very simple: Both operands must be integral types (see JLS, � 15.19). Therefore: 1.) second operand is a string - false 2.) both operands are integers - ok 3.) second operand is a double, which is not an integral - false 4.) both operands are integral types (first is integer, second is long) - ok Integral types are:

When LHS of the shift operator is an int only lower 5 bits of the RHS are used. Option 2 as it is is straight forward, and for option 4 if you need to apply the rule above. HTH, - Manish

vinita Kh
Ranch Hand

Joined: Feb 19, 2002
Posts: 49

posted May 08, 2002 23:35:00

0

Hi everybody, though its a silly question I understand option 1 and 3 are wrong. but i can't understand how 2 & 4 are correct. If i'm not wrong whenever we left shift a number it gets doubled, so in case of option 4--- j = i<<1, result that means i<<1 should be 2 , then how its equal to j. in option 2-- j = i<<j, how to calculate this? thanks, vinita