What results from running the following code?
1. public class Main { 2. public static void main(String args[]) { 3. byte b = 10; // 00001010 binary 4. byte c = 15; // 00001111 binary 5. b = (byte)(b ^ c); 6. System.out.println("b contains " + b); 7. } 8. }
B.
The XOR operator produces a 1 bit in any position where the operand bits are different.
So 00001010 ^ 00001111 is 00000101, which is 5.