Back to marketplace

Module 03: Boolean Expressions and if Statements

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

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

Card preview (24)

#1
Front (Question)

What will this code return given checkMethod(false, true)?

Card front image
Back (Answer)

-1

#2
Front (Question)

What will this method call output given yesOrNo(true)?

Card front image
Back (Answer)

“Yes”

#3
Front (Question)

Given the following call, what value would be returned for findTheMiddle(2110890125)?

Card front image
Back (Answer)

89

#4
Front (Question)

Which expression is true? • true && !true • !false || !true • true && false • false || false || !true

Back (Answer)

• !false || !true

#5
Front (Question)

What will this code output? • Hello Karel • Hello Karel Second if statement! • Second if statement! • This program will print nothing

Card front image
Back (Answer)

• Second if statement!

#6
Front (Question)

What will this program print if the value of grade is 80?

Card front image
Back (Answer)

C

#7
Front (Question)

What will the values of x and y be after this code segment runs? • x = 100 y = 200 • x = 99 y = 100 • x = 101 y = 201 • x = 99 y = 199

Card front image
Back (Answer)

• x = 99 ​y = 199

#8
Front (Question)

A company uses the following table to determine pay rate based on hours worked: Which of the following test cases can be used to show that the code does NOT work as intended? • calculateRate(35); • calculateRate(40); • calculateRate(45); • calculateRate(55);

Card front image
Back (Answer)

• calculateRate(40);

#9
Front (Question)

Assuming a and b are properly initialized boolean values, which expression would be equivalent to the following: !(a && b) • a || b • !(a || b) • !a && !b • !a || !b

Back (Answer)

• !a || !b

#10
Front (Question)

A student is trying to determine if the following two expressions are equivalent. A. x && (!x || y) B. x && !(x || !y) What values of x and y would prove that the expressions are NOT equivalent? x = true y = true x = true y = false x = false y = true x = false y = false

Back (Answer)

x = true y = true

#11
Front (Question)

Given a, b, and c are properly initialized boolean values, what values would make the following expression false? (a || b) || (b || c) || (!a || b); • a and b must be different values • a must be false • b and c must have the same values • Nothing. The expression will always be true.

Back (Answer)

• Nothing. The expression will always be true

#12
Front (Question)

In order to ride the zip line, you need to be at least 12 years old and weigh at least 75 pounds, but no more than 300 pounds. Which of the following code segments would correctly determine if you can ride the zip line? I and II only I only II only III only I, II, III

Card front image
Back (Answer)

II only

#13
Front (Question)

What will the following code output when executed?

Card front image
Back (Answer)

BC

#14
Front (Question)

The following code is intended to return only even numbers. If an even number is passed to the method, it should return that number. If an odd number or zero is passed, it should return the next highest even number. Does the code work as intended? • Yes. • No, the mod function on line 3 should read number % 2 == 1 to find even numbers. • No, the else if on line 7 and the else on line 11 should just be if statements. • No. Zero will get returned on line 5 and not make it to line 7.

Card front image
Back (Answer)

• No. Zero will get returned on line 5 and not make it to line 7

#15
Front (Question)

Given the following statements, which options will print true? • String ursa = new String(“2849”);* • String major = new String(“2849”);* I. System.out.println(ursa.equals(major)); II. System.out.println(ursa == major); III. System.out.println(ursa.equals(“2849”)); IV. System.out.println(major == “2849”); I, II, III, and IV IV only I, III, and IV only II and IV only I and III only

Back (Answer)

I and III only

#16
Front (Question)

What will the final values of x and y be if their initial values are: x = 12; y = 5;

Card front image
Back (Answer)

x = 24 y = 20

#17
Front (Question)

Assuming weekday and holiday are properly initialized booleans, which expression would be equivalent to the following: !(!weekday || holiday) • weekday || !holiday • weekday && !holiday • !weekday && !holiday • !(weekday || !holiday)

Back (Answer)

• weekday && !holiday

#18
Front (Question)

The following method is designed to return true if the passed phrase contains either the word cat or dog. Which of the following test cases can be used to show the code does NOT work as intended? • containsPet(“I have a dog.”); • containsPet(“I don’t have pets.”); • containsPet(“I can catch fish.”); • containsPet(“My dog caught my cat”);

Card front image
Back (Answer)

• containsPet(“I can catch fish.”);

#19
Front (Question)

What will the following code output when executed?

Card front image
Back (Answer)

Long Word Medium Word

#20
Front (Question)

What values for x and y will cause the program to execute the /* missing code */?

Card front image
Back (Answer)

x = 12 y = 12

#21
Front (Question)

Look at the following code and explain what the result is for each print statement and why.

Card front image
Back (Answer)

System.out.println(s1 == s2); // True: s2 is refering to the same object as s1, so the “==” operator will return as true since the two strings are referring to the same address. System.out.println(s1 == s3); // False: s1 is a string while s3 is an object, so they are not referring to the memory address System.out.println(s4 == s3); // False: since s4 is a new string - though it is referring to the value of s3 - it is allocated its own address; hence they are not the same memory location and therefore not equal. System.out.println(s4 == s5); // True: since s5 is referring to the memory of s4 so the address comparison is true (compared to the line above where the content was equal but not the address) System.out.println(s1.equals(s2)); // True: the value is true since s1 and s2 have the same content so they content is equal. System.out.println(s1.equals(s3)); // True: though one is a string and one is an object, both have the same content, notably “Hello,” so they will be true through a content comparison

#22
Front (Question)

What are rational operators?

Back (Answer)

==, !=, , <=, >= Allow for the comparison or primitive type values. Results are stored as Boolean values

#23
Front (Question)

What are Boolean operators?

Back (Answer)

Booleans can also use Relational Operators to store true/false information Relational Operators are used to comparing the values of two expressions

#24
Front (Question)

What is an equality operator?

Back (Answer)

== Returns true is both the operators are referring to the same object