Java Operators
Java Operators - Important Points
| 16. | Which of the following operators is used to decrement a variable by 1? |
|---|
A. +=
B. ++
C. --
D. *
View Answer Discuss Work SpaceAnswer: option c
Explanation:
The -- operator is used to decrement a variable by 1. For example, i-- is equivalent to i = i - 1.
| 17. | What is the result of the expression 5 >= 5? |
|---|
A. 1
B. 0
C. 1
D. 0
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The >= operator is used to test if the left operand is greater than or equal to the right operand. In this case, both operands are equal, so the result is true.
| 18. | Which of the following is the correct operator for modulo division? |
|---|
A. %
B. /
C. //
D. *
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The % operator is used for modulo division, which gives the remainder after division.
| 19. | What is the result of the expression (10 > 5) || (3 < 1)? |
|---|
A. 1
B. 0
C. 1
D. 0
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The || operator is the logical OR operator. If either of the operands is true, the result is true.
| 20. | Which of the following operators is used to test if a variable refers to the same object as another variable? |
|---|
A. !=
B. ==
C. <=
D. >=
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The == operator is used to test if two variables refer to the same object in Java. Note that this is different from testing if two objects are equal.