1) What are the two possible Logical Operator types?
A) Bitwise Logical
2) Boolean logical operators in Java work with?
A) true/false boolean data
B) 1 and 0 of individual Bits
C) characters of a String
3) Bitwise logical operators in Java work with?
A) true/false boolean data
B) 0 and 1 individual bits of data
C) Characters of a String
4) In general Bitwise logical operators are simply called?
A) Logical operators
Explanation:
Yes. Do not call Bitwise operators by adding the word Logical. It is confusing for any one.
5) What is the input for Logical Operators?
A) 1 and 0
6) What is the output of any Logical operation in Java?
A) 1 or 0
7) Which is the Logical operator in Java that works with a Single Operand?
A) Logical AND
8) Which among the following is a Logical Unary NOT operator in Java?
A) ~
Explanation:
~ is a Bitwise Unary NOT that complements bits from 0 to 1 and 1 to 0.
9) What is the output of the Java code snippet?
boolean b=false;
b = !b;
System.out.println(b);
A) true
10) Which among the following is a Short Circuit AND operator?
Explanation:
Two ampersands &&
11) Which among the following is a Short Circuit OR operator?
Explanation:
Two Pipes ||
12) What is the output of a Logical OR (|) operation if one of the inputs/operands is false?
A) false
Explanation:
Logical OR operator give true as output if at least one of the operands is true.
13) What is the output of Logical AND (&) operation if one of the inputs/operands is false?
A) false
Explanation:
false & (anything) is false.
14) What is the output of a Logical OR (|) operation if one of the inputs/operands is true?
A) false
Explanation:
true | (anything) is true.
15) What is the output of a Logical AND (&) operation if one of the inputs/operands is true?
A) false
Explanation:
true & (anything) = true or false
16) What is the output of a Logical AND (&) operation if both inputs/operands are true?
A) false
17) What is the output of a Logical OR (|) operation if both the inputs/operands are true?
A) true
18) Which is fast among AND (&) and Short Circuit AND(&&) operators in Java?
A) AND operator
C) Both work at the same speed
19) Which is fast among OR(|) and Short Circuit OR (||) operators in Java?
A) OR Operator
B) Short Circuit OR operator
C) Both work at the same speed
20) Why are Short Circuit AND (&&) and Short Circuit OR (||) operators are fast in Java?
A) By skipping the second expression or operand if possible and save time.
B) By using extra memory on the machine
C) By using extra CPU processing power
Explanation:
Short Circuit operators are not 100% every time. Based on the value of the First operand, they decide whether to go evaluating the second expression.