Multiple choice technology programming languages

The '&' operator in java

  1. sets a bit to 1 if both operand's bits are 1

  2. sets a bit to 1 if only one operand's bit is 1.

  3. sets a bit to 1 if at least one operand's bit is 1

  4. reverses the value of every bit in the operand

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The bitwise AND operator (&) compares each bit position and sets the result bit to 1 only when both corresponding operand bits are 1. This differs from OR (at least one bit is 1), XOR (exactly one bit is 1), and complement (reverses all bits). The AND operation is commonly used for masking and checking specific bit patterns.