MCQ PracticeSingle Best AnswerTopic: 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 ✔✖
C
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.