Java Operators
Java Operators - Important Points
31. | What is the result of the expression 4 % 2? |
---|
A. 0
B. 1
C. 2
D. 4
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The % operator is used for modulo division, which gives the remainder after division. In this case, 4 divided by 2 leaves a remainder of 0.
32. | Which of the following operators is used to compare two values for greater than? |
---|
A. !=
B. ==
C. >=
D. >
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The > operator is used to test if the left operand is greater than the right operand.
33. | What is the result of the expression 2 + 2 * 3? |
---|
A. 6
B. 8
C. 10
D. 8
View Answer Discuss Work SpaceAnswer: option d
Explanation:
In Java, multiplication and division have higher precedence than addition and subtraction. Therefore, 2 * 3 is evaluated first, resulting in 6. Then, 2 is added to 6 to get the final result of 8.
34. | Which of the following operators is used to perform a bitwise right shift operation? |
---|
A. <<
B. >>
C. &
D. |
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The >> operator is used to perform a bitwise right shift operation in Java.
35. | What is the result of the expression true && false? |
---|
A. 1
B. 0
C. 1
D. 0
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The && operator is the logical AND operator. Both operands must be true for the result to be true.