Unit 3: Boolean Expressions & if Statements Flashcards Preview

AP CS-Applications > Unit 3: Boolean Expressions & if Statements > Flashcards

Flashcards in Unit 3: Boolean Expressions & if Statements Deck (13)
Loading flashcards...
1

Under what conditions does an if statement execute?

An if statement executes when the boolean expression within the parentheses is true.

2

How do you compare Strings?

You compare strings through the ".equals()" method, which returns a boolean expression.

3

What is the difference between = and == ?

= is used to assign values
== is used when checking equality

4

Which of the following symbols is the “not equal” symbol?

a) =!
b) ==
c) !=
d) !!

c) !=

5

Under what conditions does an else statement execute?

Else statements execute if the initial boolean expression evaluates to false

6

What is the purpose of an else if statement?

Else if statements allow us to incorporate additional conditions to if-else statements

7

!(true && false) || (false && false)

true

8

What are the 3 logical operators?

NOT !
AND &&
OR ||

9

What is the not operator?

!(not) evaluates a condition to the opposite boolean value

10

Are both of these equivalent?

p && !q || !p && q
(p || q) && (!p || !q)

yes

11

What is the and operator?

The &&(and) evaluates whether all conditions are true

12

What is the or operator?

|| (or) evaluates whether one condition is true

13

Do boolean operators also have an order of operations?

Yes!