Q: What is the output of a Bitwise Exclusive OR (^) operation if both the inputs/operands are different?
Solution: 0 ^ 1 = 1; 1 ^ 0 = 1;
Q: What does this Java code snippet prints? int b=45; String str=""; while(b > 0) { str = str + b%2; b = b/2; } StringBuilder sb = new StringBuilder(str); sb.reverse(); System.out.println(sb.toString());
Solution: The output is 101101 (45).
Q: What is the output of a Bitwise OR (|) operation if one of the inputs/operands is 0?
Solution: 0 | P = 1 if P==1 0 | P = 0 if P==0
Q: What is the output of the Java code snippet? System.out.println(0b0000_1000);
Solution: Binary literals start with 0b. Above number is 8 in decimal notation.
Q: What is the output of a Bitwise AND (&) operation if both the inputs/operands are 1s?
Solution: 1 & 1 = 1
Q: What is the output of a Bitwise Exclusive OR (^) operation if both of the inputs/operands are 0s or 1s?
Solution: 0 ^ 0 = 0; 1 ^ 1 = 1;
Q: What is the output of a Bitwise AND (&) operation if one of the inputs/operands is 1?
Solution: 1 & (P) = 1 if P=1 1 & (P) = 0 if P=0
Q: What is the output of a Bitwise OR (|) operation if one of the inputs/operands is 1?
Solution: 1 | (anything) = 1
Q: What is the output of a Bitwise AND (&) operation if one of the inputs/operands is 0?
Solution: 0 & (anything) = 0
Q: What is the output of a Bitwise OR (|) operation if both the inputs are 1s?
Solution: 1 | 1 = 1
You Have Score    | /10 |