What will be the output of the program? - ProProfs Discuss
Advertisement

What will be the output of the program?

Class BitShift 
{
 public static void main(String [] args) 
 {
 int x = 0x80000000;
 System.out.print(x + " and ");
 x = x >>> 31;
 System.out.println(x);
 }
}

Asked by Frey, Last updated: Apr 17, 2024

+ Answer
Request
Question menu
Vote up Vote down

1 Answer

John Smith

John Smith

John Smith
John Smith

Answered Sep 09, 2016

-2147483648 and 1.

The >>> operator moves all bits to the right, zero filling the left bits. The bit transformation looks like this: Before: 1000 0000 0000 0000 0000 0000 0000 0000 After: 0000 0000 0000 0000 0000 0000 0000 0001.

upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.