AP Computer Science Principles Practice Quiz: Nested Conditionals
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Test your understanding with short quizzes. This quiz has 7 questions to check your progress.
Question 1 of 7
All Questions (7)
A) A series of conditional statements executed one after another.
B) A conditional statement that is placed inside the block of another conditional statement.
C) A loop that contains a conditional statement.
D) A conditional statement that can only evaluate to true.
Correct Answer: B
Based on the provided content, 'Nested conditional statements consist of conditional statements within conditional statements.' This means one conditional is placed inside another.
A) Apple
B) Banana
C) Cherry
D) Nothing is printed.
Correct Answer: B
The outer condition `x > 5` (10 > 5) is true. The program then evaluates the inner conditional. The inner condition `y < 3` (5 < 3) is false. Therefore, the `else` block of the inner conditional is executed, printing 'Banana'.
A) Pending
B) A
C) B+
D) B
Correct Answer: D
The first condition `score >= 90` (88 >= 90) is false, so the outer `else` block is executed. Inside this block, the nested condition `hasExtraCredit` (which is false) is checked. Since it is false, the inner `else` block is executed, setting `status` to 'B'.
A) temperature = 50, isRaining = true
B) temperature = 70, isRaining = false
C) temperature = 50, isRaining = false
D) temperature = 70, isRaining = true
Correct Answer: C
To print 'Wear a jacket', the outer condition `temperature < 60` must be true, and the inner condition `isRaining` must be false. Option C (temperature = 50, isRaining = false) is the only one that satisfies both conditions.
A) Red
B) Green
C) Blue
D) Nothing is printed.
Correct Answer: B
The first condition `a < b` (5 < 10) is true, so the outer `if` block is executed. The next condition `c < b` (15 < 10) is false, so its `else` block is executed. Inside that `else` block, the condition `a < c` (5 < 15) is true, which causes 'Green' to be printed.
A) if (condition1) { ... } if (condition2) { ... }
B) if (condition1) { if (condition2) { ... } }
C) if (condition1) { ... } else if (condition2) { ... }
D) while (condition1) { if (condition2) { ... } }
Correct Answer: B
A nested conditional statement is defined as a conditional statement within another conditional statement. Option B shows an `if` statement for `condition2` placed directly inside the code block of the `if` statement for `condition1`, which is the correct structure.
A) 1
B) 2
C) 3
D) 4
Correct Answer: B
The outer condition `x >= 10` (10 >= 10) is true, so the program enters the first main block. The inner condition `y > 10` (10 > 10) is false. Therefore, the `else` part of this inner block is executed, setting `z` to 2. The entire outer `else` block (which would set z to 3 or 4) is skipped.