Multiple choice

What will be the output of the given program? class BitShift { public static void main(String [] args) { int x = 0x80000000; System.out. print(x + and) ; x = x >>> 31; System.out. println(x); } }

  1. -2147483648 and 1

  2. 0x80000000 and 0x00000001

  3. -2147483648 and -1

  4. 1 and -2147483648

  5. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Option (1) is correct. 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 Converting this into decimal, the result will be 2147483648 and 1 So, this is the correct choice.