0
0
Javaprogramming~5 mins

Relational operators in Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
A<=
B==
C!=
D=
What is the result type of the expression (5 < 10)?
Aboolean
Bint
CString
Ddouble
Which operator would you use to check if a number is greater than or equal to another?
A<=
B>=
C==
D!=
What does the expression (a == b) check?
AIf a is equal to b
BIf a is not equal to b
CIf a is greater than b
DIf a is assigned b
Which of these is NOT a relational operator in Java?
A>=
B!=
C<
D&&
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.