File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mock Exam Errata and the fly likes Unsigned right-shift operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Unsigned right-shift operator" Watch "Unsigned right-shift operator" New topic
Author

Unsigned right-shift operator

Lam Thai
Ranch Hand

Joined: Apr 02, 2001
Posts: 117
Hello,
Question #305 in Javaranch mock exam:
What does an unsigned right-shift operator do to a negative number? You have two choices: a) change its sign and b) keep it negative.
I believe the question needs to be changed as the following snippet of code would cause confusion:
int i1 = -1;
i1 >>>= 1;
System.out.println(x1); // positive - change sign
short s1 = -1;
s1 >>>= 1;
System.out.println(s1); // negative - keeps sign
Maybe the question should be replaced with more specific questions as shown with the examples.
Regards,
Lam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unsigned right-shift operator