MCQ Practice Single Best Answer Topic: Bitwise Operators

Q What is the value of the expression m &= 7 after it is executed in Java, where m is initially 15?

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

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 0
  • B 7
  • C 8
  • D 15
Correct Answer: A

Explanation

The bitwise AND assignment operator (&=) in Java performs a bitwise AND 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, m &= 7 is equivalent to 00001111 & 00000111, resulting in 00000111, which is 7 in decimal.

Share This Question

Share this MCQ with your friends or study group.