Back to marketplace

Unit 3: Boolean Expressions & if Statements

No description yet. This curated deck is ready for daily study.

Total cards: 22•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (22)

#1
Front (Question)

Under what conditions does an if statement execute?

Back (Answer)

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

#2
Front (Question)

How do you compare Strings?

Back (Answer)

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

#3
Front (Question)

What is the difference between = and == ?

Back (Answer)

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

#4
Front (Question)

Which of the following symbols is the “not equal” symbol? a) =! b) == c) != d) !!

Back (Answer)

c) !=

#5
Front (Question)

Under what conditions does an else statement execute?

Back (Answer)

Else statements execute if the initial boolean expression evaluates to false

#6
Front (Question)

What is the purpose of an else if statement?

Back (Answer)

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

#7
Front (Question)

Will it return true or false? !(true && false) || (false && false)

Back (Answer)

true

#8
Front (Question)

What are the 3 logical operators?

Back (Answer)

NOT ! AND && OR ||

#9
Front (Question)

What is the not operator?

Back (Answer)

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

#10
Front (Question)

Are both of these equivalent? p && !q || !p && q p || q) && (!p || !q

Back (Answer)

yes

#11
Front (Question)

What is the and operator?

Back (Answer)

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

#12
Front (Question)

What is the or operator?

Back (Answer)

|| (or) evaluates whether one condition is true

#13
Front (Question)

Do boolean operators also have an order of operations?

Back (Answer)

Yes!

#14
Front (Question)

What would the output be for the following code double x = 15.0/11.0; System.out.println(11.0*x == 15.0);

Back (Answer)

False

#15
Front (Question)

Is this statement true? !(a && b) == !a or !b

Back (Answer)

True statement, De Morgan’s law

#16
Front (Question)

When && and || are combined in one logical expression, which one has a higher rank?

Back (Answer)

&& has a higher rank

#17
Front (Question)

How do you do the opposite of De Morgan’s law? !(a || b) == ?????????

Back (Answer)

!a and !b, distribute negation and flip symbol

#18
Front (Question)

The boolean expression a[i] == max || !(max != a[i]) can be simplified to: (A) a[i] == max (B) a[i] != max (C) a[i] < max || a[i] > max (D) true (E) false

Back (Answer)

(A) a[i] = max

#19
Front (Question)

When does short circuit evaluation come into play?

Back (Answer)

When there is multiple conditions. Also, the conditions are run in order: Not all conditions are ran

#20
Front (Question)

What will this code return given checkMethod(false, true)? public int checkMethod(boolean x, boolean y) { if(!x) { if(y) { return -1; } else { return 1; } } else { return 0; } }

Back (Answer)

-1

#21
Front (Question)

Given the following call, what value would be returned for findTheMiddle(2110890125)? public static String findTheMiddle(int number) { String stringNum = “” + number; int mid = stringNum.length()/2; if(stringNum.length() % 2 == 1) { return stringNum.substring(mid,mid+1); } else { return stringNum.substring(mid-1,mid+1); } }

Back (Answer)

89

#22
Front (Question)

What will this program print if the value of grade is 80? if(grade > 90) { System.out.println("A"); } else if(grade > 80) { System.out.println("B"); } else if(grade > 70) { System.out.println("C"); }

Back (Answer)

C