MCQ Practice Single Best Answer Topic: Bitwise Operators

Q What is the value of p >> 2 after the expression is executed in Java, where p is 24?

Question ID
#20167
Subchapter
Bitwise Operators
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 4
  • B 6
  • C 8
  • D 12
Correct Answer: C

Explanation

The right shift operator (>>) in Java shifts the bits of the left operand to the right by the number of positions specified by the right operand. In this case, p >> 2 is equivalent to 00011000 >> 2, resulting in 00000011, which is 6 in decimal.

Share This Question

Share this MCQ with your friends or study group.