76). It is not possible for the two’s complement value to be equal to the original value in any case.
[A]True
[B]False
[C]none
[D]none of the mentioned
Show Answer
Correct Answer: False
Notes:
Answer: b
Explanation: In most cases the value of two’s complement is different from the original value. However, there are cases in which the two’s complement value may be equal to the original value. For example, the two’s complement of 10000000 is also equal to 10000000. Hence the statement is false.
77). The one’s complement of 110010101 is:
[A]001101010
[B]110010101
[C]001101011
[D]110010100
Show Answer
Correct Answer: 001101010
Notes:
Answer: a
Explanation: The one’s complement of a value is obtained by simply changing all the 1’s to 0’s and all the 0’s to 1’s. Hence the one’s complement of 110010101 is 001101010.
78). Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.
[A]OR
[B]AND
[C]XOR
[D]NOT
Show Answer
Correct Answer: XOR
Notes:
Answer: c
Explanation: Bitwise XOR gives 1 if either of the bits is 1 and 0 when both of the bits are 1.
79). What will be the output of the following Python expression?
4^12
Show Answer
Correct Answer: 8
Notes:
Answer: c
Explanation: ^ is the XOR operator. The binary form of 4 is 0100 and that of 12 is 1100. Therefore, 0100^1100 is 1000, which is equal to 8.
80). Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on being AND-ed with this value always gives 0.
4^12
Show Answer
Correct Answer: 1
Notes:
Answer: c
Explanation: Any odd number on being AND-ed with 1 always gives 1. Any even number on being AND-ed with this value always gives 0.
81). What will be the value of the following Python expression?
bin(10-2)+bin(12^4)
[A]0b10000
[B]0b10001000
[C]0b1000b1000
[D]0b10000b1000
Show Answer
Correct Answer: 0b10000b1000
Notes:
Answer: d
Explanation: The output of bin(10-2) = 0b1000 and that of bin(12^4) is ob1000. Hence the output of the above expression is: 0b10000b1000.
82). Which of the following expressions can be used to multiply a given number ‘a’ by 4?
bin(10-2)+bin(12^4)
[A]a<<2
[B]a<<4
[C]a>>2
[D]a>>4
Show Answer
Correct Answer: a<<2
Notes:
Answer: a
Explanation: Let us consider an example wherein a=2. The binary form of 2 is 0010. When we left shift this value by 2, we get 1000, the value of which is 8. Hence if we want to multiply a given number ‘a’ by 4, we can use the expression: a<<2.
83). What will be the output of the following Python code if a=10 and b =20?
a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)
[A]10 20
[B]10 10
[C]20 10
[D]20 20
Show Answer
Correct Answer: 20 10
Notes:
Answer: c
Explanation: The code shown above is used to swap the contents of two memory locations using bitwise X0R operator. Hence the output of the code shown above is: 20 10.
84). What is the two’s complement of -44?
a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)
[A]1011011
[B]11010100
[C]11101011
[D]10110011
Show Answer
Correct Answer: 11010100
Notes:
Answer: b
Explanation: The binary form of -44 is 00101100. The one’s complement of this value is 11010011. On adding one to this we get: 11010100 (two’s complement).
85). What will be the output of the following Python expression?
~100?
[A]101
[B]-101
[C]100
[D]-100
Show Answer
Correct Answer: -101
Notes:
Answer: b
Explanation: Suppose we have an expression ~A. This is evaluated as: -A – 1. Therefore, the expression ~100 is evaluated as -100 – 1, which is equal to -101.