Java OCA OCP Practice Question 532

Question

What is -50 >> 1?

  • A. A negative number with very large magnitude.
  • B. A positive number with very large magnitude.
  • C. -100
  • D. -25
  • E. 100
  • F. 25


D.

Note

>> is the signed right-shift operator.

The result has the same sign as the left-hand operand.

Right-shifting by n bit positions is equivalent to dividing by 2-to-the-n, so the result is -50 / 2, which is -25.




PreviousNext

Related