MCQ Practice Single Best Answer Topic: Bitwise Operators

Q If b is 9 and c is 2, what is the value of b ^= c after the expression is executed in Java?

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

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 2
  • B 7
  • C 9
  • D 11
Correct Answer: D

Explanation

The bitwise XOR assignment operator (^=) in Java performs a bitwise XOR operation between the variable on the left-hand side and the value on the right-hand side and assigns the result to the variable. In this case, b ^= c is equivalent to 00001001 ^ 00000010, resulting in 00001011, which is 11 in decimal.

Share This Question

Share this MCQ with your friends or study group.