aspose file tools*
The moose likes Beginning Java and the fly likes operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "operators" Watch "operators" New topic
Author

operators

Rally Krish
Greenhorn

Joined: Jul 20, 2006
Posts: 5
What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.

public class test {
public static void main(String args[]) {
int x;

x = -3 >> 1;
x = x >>> 2;
x = x << 1;
System.out.println(x);
}
}

ans is given as 2147483646

can anyone please explain

Thanks in advance
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
0000 0000 0000 00113
1111 1111 1111 1100 inverting and adding 1 gives
1111 1111 1111 1101-3

1111 1111 1111 1110>> 1 (sign carried)

0011 1111 1111 1111>>> 2 (0 inserted)

0111 1111 1111 1110hence, the result


SCJP 1.4 85%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: operators