Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

khalid's test que -2

 
mads pawar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statements are true concerning the effect of the >> and >>> operators?
select all valid asn.
one of the corrcect ans given is
(d)The value returned by >>> will never be negative as long as the value of the right operand is equal to or greater than 1.
i think it is not correct ans.
--------
int i=-1;
system.out.println("using >>> and right op is >1 :res : "+i>>>32);
------------
out put: using >>> and right op is >1 :res : -1
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your right, >>> will usually give a positive number but not always as in the case you pointed out. Should say will give you a positive result when the number on the RHS is not the same bit size as the value on the LHS. Well that is probably poor wording, but something like that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic