Flashcards in Unit 3: Boolean Expressions & if Statements Deck (13)
Under what conditions does an if statement execute?
An if statement executes when the boolean expression within the parentheses is true.
How do you compare Strings?
You compare strings through the ".equals()" method, which returns a boolean expression.
What is the difference between = and == ?
= is used to assign values
== is used when checking equality
Which of the following symbols is the “not equal” symbol?
Under what conditions does an else statement execute?
Else statements execute if the initial boolean expression evaluates to false
What is the purpose of an else if statement?
Else if statements allow us to incorporate additional conditions to if-else statements
!(true && false) || (false && false)
What are the 3 logical operators?
What is the not operator?
!(not) evaluates a condition to the opposite boolean value
Are both of these equivalent?
p && !q || !p && q
(p || q) && (!p || !q)
What is the and operator?
The &&(and) evaluates whether all conditions are true
What is the or operator?
|| (or) evaluates whether one condition is true