Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

khalid's test que -2  RSS feed

 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!