Recall & Review
beginner
What are relational operators in Java?
Relational operators compare two values and return a boolean result: true or false. They help decide if one value is greater, smaller, equal, or not equal to another.
Click to reveal answer
beginner
List the six main relational operators in Java.
The six main relational operators are: < (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to), == (equal to), != (not equal to).
Click to reveal answer
beginner
What is the result type of a relational operator expression in Java?
The result is always a boolean value: either true or false.
Click to reveal answer
beginner
Explain the difference between == and = in Java.
== is a relational operator that checks if two values are equal. = is an assignment operator that sets a value to a variable.
Click to reveal answer
beginner
What will be the output of this code snippet?
int a = 5, b = 10;
System.out.println(a > b);
The output will be false because 5 is not greater than 10.
Click to reveal answer
Which operator checks if two values are NOT equal in Java?
✗ Incorrect
!= means not equal, so it returns true if values differ.
What is the result type of the expression (5 < 10)?
✗ Incorrect
Relational operators always return a boolean value: true or false.
Which operator would you use to check if a number is greater than or equal to another?
✗ Incorrect
>= means greater than or equal to.
What does the expression (a == b) check?
✗ Incorrect
== checks if two values are equal.
Which of these is NOT a relational operator in Java?
✗ Incorrect
&& is a logical AND operator, not a relational operator.
Explain what relational operators do in Java and give examples.
Think about how you compare numbers or values in daily life.
You got /4 concepts.
Describe the difference between == and = in Java and why confusing them can cause errors.
One is for comparison, the other for setting values.
You got /4 concepts.