Consider the following code, assuming grade is an int: Which of the following will always produce the same result as the code above, regardless of the value of grade?
AP CS A Unit 3 Review

Flashcard
•
Computers
•
11th - 12th Grade
•
Hard
Quizizz Content
FREE Resource
Student preview

19 questions
Show all answers
1.
FLASHCARD QUESTION
Front
Back
Answer explanation
This code will replace the original and always work the same. If the grade is less
than or equal to 75, Eh is printed. If grade is greater than or equal to 100, Great is
printed and then the rest in between will receive Good.
2.
FLASHCARD QUESTION
Front
What is output by the following code? Options: 11, 15, 31, error
Back
11
Answer explanation
The x * 3 is equal to 30 so the first if runs and increments x (which is 10) by one. Then
since 11 is smaller than 31, it will not run the second if, thus printing 11
3.
FLASHCARD QUESTION
Front
Consider the following incomplete code segment. Consider the following potential replacements for /* missing code */. Which of these replacements will cause the code segment to always print false? Assume that Math is imported correctly into our program: (int)(Math.random() * 10) + 20, (int)(Math.random() * 10) + 25, (int)(Math.random() * 10) + 30, (int)(Math.random() + 30)
Back
(int)(Math.random() * 10) + 20
Answer explanation
Math.random() returns a random value between 0 (inclusive)
and 1 (exclusive). So Math.random()*10 + 20 can give values
between 20.0 and 29.9999... By typecasting the value to an int,
the decimal values are truncated, which gives a range from 20 to
29 inclusive, meaning it never returns 30, and false is always
printed as a result
4.
FLASHCARD QUESTION
Front
Given the variables, which boolean condition is true? Options: a < b && a == b, a > b || a != b, a < b && a != b, b >= a && a >= b
Back
b >= a && a >= b
Answer explanation
This is equivalent to a == b, which is true
5.
FLASHCARD QUESTION
Front
The following if statement tests the snowfall in Alaska during the months of December, January and February. Assume low represents a threshold determined to be the least amount of snow required to be normal and high represents a threshold determined to be the most amount of snow required to be normal and snow represents the amount of snow in inches for that month. All variables are doubles. It could be replaced with:
Back
Answer explanation
This solution properly splits up the compound boolean expression and created two
nested if/else statements
6.
FLASHCARD QUESTION
Front
The following truth table matches which boolean condition?
Options: A && ( A || B ), A && ( A && B ), !A && ( A || !B ), A || ( A || B )
Back
A || ( A || B )
Answer explanation
This is equivalent to A || B which the truth table reflects
7.
FLASHCARD QUESTION
Front
To test if a grade (represented by the double variable g) is a B (between 80 - inclusive - and 90 exclusive) you would use the following if statement: What set of three symbols correctly fills in the blanks in the order they appear? Options: >=, &&, <, >=, ||, <, >, ||, <=, <=, &&, >
Back
>=, &&, <
Answer explanation
We want inclusive of the lower bound and exclusive of the upper bound, so we
need to use >= and <, and we need both conditions to be true so we use &&
Create a free account and access millions of resources
Similar Resources on Quizizz
15 questions
Chapter 17: From Gene to Protein [Protein Synthesis]

Flashcard
•
11th - 12th Grade
18 questions
AP CSA Unit 1 Review

Flashcard
•
10th - 12th Grade
15 questions
AP CSP Unit 4

Flashcard
•
10th - 12th Grade
15 questions
While Loops

Flashcard
•
11th Grade - University
13 questions
OCR A Level Computer Science (H446) - Component 1.1.2 - Types of Processor

Flashcard
•
11th Grade - University
17 questions
AP CS A Unit 3 Review

Flashcard
•
11th - 12th Grade
16 questions
Lesson 3.5 - If Structures Practice

Flashcard
•
11th Grade
12 questions
VdL Java Inheritance Flashcard

Flashcard
•
11th Grade
Popular Resources on Quizizz
15 questions
Multiplication Facts

Quiz
•
4th Grade
25 questions
SS Combined Advisory Quiz

Quiz
•
6th - 8th Grade
40 questions
Week 4 Student In Class Practice Set

Quiz
•
9th - 12th Grade
40 questions
SOL: ILE DNA Tech, Gen, Evol 2025

Quiz
•
9th - 12th Grade
20 questions
NC Universities (R2H)

Quiz
•
9th - 12th Grade
15 questions
June Review Quiz

Quiz
•
Professional Development
20 questions
Congruent and Similar Triangles

Quiz
•
8th Grade
25 questions
Triangle Inequalities

Quiz
•
10th - 12th Grade
Discover more resources for Computers
40 questions
Week 4 Student In Class Practice Set

Quiz
•
9th - 12th Grade
40 questions
SOL: ILE DNA Tech, Gen, Evol 2025

Quiz
•
9th - 12th Grade
20 questions
NC Universities (R2H)

Quiz
•
9th - 12th Grade
25 questions
Triangle Inequalities

Quiz
•
10th - 12th Grade
10 questions
Right Triangles: Pythagorean Theorem and Trig

Quiz
•
11th Grade
65 questions
MegaQuiz v2 2025

Quiz
•
9th - 12th Grade
10 questions
GPA Lesson

Lesson
•
9th - 12th Grade
15 questions
SMART Goals

Quiz
•
8th - 12th Grade