This activity looks at relational and logical operators.
In addition to the discussion of the solution in the Solution document, the project for this activity contains two classes:
The method checkTruthValues defines some primitive data values and then evaluates and prints out six expressions. At present, every expression evaluates to the boolean value false. Your job is to alter one of the operators, but not the variables, in each of these expressions, so that the new versions all then evaluate to true.
To give an example of what we mean, take the statement
x = (A == B) || D;
If A were 10, B were 42 and D boolean false, the expression on the right-hand side would evaluate to false. One way to make it evaluate to true by changing one operator would be to change the statement to
x = (A != B) || D;
There are usually several ways of achieving a true expression by changing one operator. For example, we could also have said:
x = (A < B) || D;