Which of the following operators is used for comparison in Java?

Java MCQ: Which of the following operators is used for comparison in Java?

a) =
b) ==
c) ++
d) &&

Answer:

b) ==

Explanation:

In Java, the == operator is used for comparison, specifically to check if two values are equal. It is different from the = operator, which is used for assignment. The == operator is commonly used in conditional statements to compare variables or expressions.

Other operators in Java include ++, which is used for incrementing a value, and &&, which is used as a logical AND operator. Each operator in Java serves a specific purpose in the evaluation of expressions and the execution of statements.

Understanding the correct use of operators is crucial for writing effective Java programs and ensuring accurate evaluation of conditions.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top