4.1.1. WriteSelection-WE1-P1¶
Write Relational Expressions
To correctly write selection statements, you must write the conditional expressions correctly. To do this, you generally need to translate the requirements, written in English, to a correct boolean expression. Below are practice questions for this skill.
WrSelect-WE1-P1
- weight > 100
- weight < 100
- weight >= 100
- weight >> 100
Q1: Which of the following is the correct Java expression that is equivalent to the English expression “weight is greater than 100”?
- a NOT EQUAL 0
- a NOT= 0
- a != 0
- a !== 0
Q2: Which of the following is the correct Java expression that is equivalent to the English expression “a not equal to 0”?
- "apple" != "orange"
- apple != orange
- NOT ("apple.equals("orange"))
- apple !== orange
Q3: Which of the following is the correct Java expression that is equivalent to the English expression “apple and orange are not the same”?
- NOT done
- != done
- !done
- done = false
Q4: Which of the following is the correct Java expression that is equivalent to the English expression “not done”?