Java Operators
Java Operators - Important Points
36. | Which of the following operators is used to compare two values for not equal to? |
---|
A. !=
B. ==
C. >=
D. <=
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The != operator is used to test if the two operands are not equal.
37. | What is the result of the expression 1 + 2 + "3"? |
---|
A. 33
B. 6
C. 123
D. 6
View Answer Discuss Work SpaceAnswer: option a
Explanation:
In Java, when a string is concatenated with a number, the number is first converted to a string. Therefore, 1 + 2 is evaluated first, resulting in 3. Then, "3" is concatenated with 3 to get the final result of "33".
38. | Which of the following operators is used to perform a logical OR operation? |
---|
A. &
B. &&
C. |
D. ||
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The || operator is the logical OR operator. If either of the operands is true, the result is true.
39. | What is the result of the expression 3 * 2 / 4? |
---|
A. 0.75
B. 1.5
C. 3
D. 6
View Answer Discuss Work SpaceAnswer: option b
Explanation:
In Java, multiplication and division have the same precedence, so they are evaluated left to right. Therefore, 3 * 2 is evaluated first, resulting in 6. Then, 6 is divided by 4, resulting in 1.5.
40. | Which of the following operators is used to perform a bitwise XOR operation? |
---|
A. &
B. &&
C. ^
D. ||
View Answer Discuss Work SpaceAnswer: option c
Explanation:
The ^ operator is used to perform a bitwise XOR operation in Java.