Multiple choice technology programming languages

Assume the bit pattern of byte x is: 10110001. What will the sign of x be after x>>2?

  1. postive

  2. negative

  3. can't be find

  4. none of the above

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

Java's >> operator performs arithmetic right shift, which preserves the sign bit. The original pattern 10110001 has MSB 1, indicating a negative value. After shifting right by 2 positions, the result is 11101100, where the sign bit remains 1, so the value is still negative. The >>> operator would perform logical right shift without sign extension.