Professional Documents
Culture Documents
Operators
What is an Equality
Operator?
The Equality operator (==) is the operator that provides a comparison of two or more operands. It returns
either True or False Value.
String a = “hello”;
String b = “hi”;
String c = “hello”;
Boolean Value
Operator symbols and/or names can vary with different programming languages. Most programming
languages use relational operators similar to the following:
Operator Meaning
Relational operators on expression comparison: Suppose that x=2, y=3 and z=6
(x ==5) // Evaluates to false since x is not equal to 5.
(x*y >=c) // Evaluates to true since (2*3 >= 6) is true.
(y+4 > x*z) // Evaluates to false since (3+4 >2*6) is false.
(x ==5) // Evaluates to false since x is not equal to 5.
Logical Operator
Same with the relational operator, a logical operator also returns Boolean values as outputs. The
logical operators (&&) and (||) are used to when evaluating two expressions to obtain one relational
result.
AND operator (&&) represents the Boolean logical operation AND. This operation results true if both its
operands are true, and false otherwise.
A !A
True False
False True
1. Which of the following is a logical Operator?
a. +
b. =
c. !
d. /
2. Which of the following is the Operator that produces Boolean values of two or more expressions?
a. Relational
b. Increment
c. Operator precedence
d. Arithmetic
2. Write a Boolean expression that declares whether a given integer is divisible by both 3 and 5, without
remainder