Complete the code to perform bitwise AND of two integers a and b.
int result = a [1] b;The bitwise AND operator is &. It compares each bit of two numbers and returns 1 only if both bits are 1.
Complete the code to perform bitwise OR of two integers x and y.
int combined = x [1] y;The bitwise OR operator is |. It returns 1 if either bit is 1.
Fix the error in the code to perform bitwise XOR of two integers m and n.
int xorResult = m [1] n;The bitwise XOR operator is ^. It returns 1 only if bits are different.
Fill both blanks to perform left shift of integer val by 3 bits and then bitwise NOT the result.
int shifted = val [1] 3; int result = [2]shifted;
Left shift operator is <<. Bitwise NOT operator is ~.
Fill all three blanks to perform right shift of number num by 2 bits, then bitwise AND with mask, and finally bitwise OR with flag.
int shifted = num [1] 2; int masked = shifted [2] mask; int result = masked [3] flag;
The right shift operator is >> (signed right shift) or >>> (unsigned right shift). In the options, >> is provided (option A). Bitwise AND is &, bitwise OR is |.
