AP Computer Science A 50 Flashcards Intermediate 100% Free

AP Computer Science A:: Boolean If

Created by Chat Robotics Community  ·  Updated 2026-09-08

Curriculum Overview

Comprehensive, high-yield AP Computer Science A study deck focusing on Boolean If. Features 50 rigorous, curriculum-aligned flashcards designed for intermediate-level mastery. Core concepts covered include Boolean If, key problem-solving heuristics, foundational formulas, and exam-tested application scenarios. Ideal for active recall review, spaced repetition study, and scoring in the top percentile.

Topics & Key Concepts

Both Fail Java Pass This FIRST Given String System Nothing

Sample Flashcard Questions & Answers

Showing 8 of 50 cards
Question #1 Active Recall

What must a BOOLEAN EXPRESSION evaluate to in Java?

- **A)** Either \(true\) or \(false\) -- no other value is possible
- **B)** Either \(0\) or \(1\), stored as integers
- **C)** A \(String\)
- **D)** Any \(int\) value

Answer & Explanation:
**Answer: A)**

A boolean expression, by definition, always evaluates to exactly one of the two \(boolean\) values: \(true\) or \(false\).
Question #2 Active Recall

What is the general syntax of a basic \(if\) statement in Java?

- **A)** \(if\ \{booleanExpression\}\ statements;\)
- **B)** \(if\ booleanExpression\ then\ statements;\)
- **C)** \(if\ (statements)\ \{\ booleanExpression;\ \}\)
- **D)** \(if\ (booleanExpression)\ \{\ statements;\ \}\), where the statements execute ONLY when the boolean expression evaluates to \(true\)

Answer & Explanation:
**Answer: D)**

Java's \(if\) statement requires the boolean expression in parentheses, followed by the block of code (in braces) to execute conditionally.
Question #3 Active Recall

Given \(int\ x = 5;\), what happens when the following code runs? \(if\ (x > 10)\ \{\ System.out.println("big");\ \}\)

- **A)** The program crashes
- **B)** "big" is printed
- **C)** Nothing is printed, since \(x > 10\) evaluates to \(false\) (5 is not greater than 10), so the block is skipped entirely
- **D)** This causes a compile-time error

Answer & Explanation:
**Answer: C)**

Since the boolean condition is \(false\), the code inside the \(if\) block never executes.
Question #4 Active Recall

What is the purpose of the \(else\) clause paired with an \(if\) statement?

- **A)** It is required after every \(if\) statement in Java
- **B)** It specifies a block of code to execute ONLY when the \(if\)'s boolean condition evaluates to \(false\)
- **C)** It specifies code that always executes, regardless of the condition
- **D)** It repeats the \(if\) block multiple times

Answer & Explanation:
**Answer: B)**

\(if\)/\(else\) provides exactly two mutually exclusive paths: one for when the condition is true, one for when it is false.
Question #5 Active Recall

Given \(int\ score = 55;\), what is printed by: \(if\ (score\ >=\ 60)\ \{\ System.out.println("Pass");\ \}\ else\ \{\ System.out.println("Fail");\ \}\)?

- **A)** Nothing is printed
- **B)** "Pass"
- **C)** Both "Pass" and "Fail" are printed
- **D)** "Fail", since \(55 \geq 60\) is \(false\), so the \(else\) branch executes instead

Answer & Explanation:
**Answer: D)**

Exactly one of the two branches runs: since the condition is false here, only the \(else\) branch's code executes.
Question #6 Active Recall

What is a CASCADING (chained) \(if\)-\(else\ if\)-\(else\) statement used for?

- **A)** It is functionally identical to a series of independent, separate \(if\) statements with no difference in behavior
- **B)** To repeat a block of code a fixed number of times
- **C)** To test a series of conditions IN ORDER, executing only the block associated with the FIRST condition that evaluates to \(true\), and skipping all remaining conditions once a match is found
- **D)** To execute every single block regardless of which conditions are true

Answer & Explanation:
**Answer: C)**

A cascading if-else-if structure evaluates conditions top to bottom and stops at the first true one -- this 'stop at first match' behavior is a key distinction from a sequence of independent \(if\) statements.
Question #7 Active Recall

Given \(int\ x = 85;\), what grade is printed by: \(if\ (x\ >=\ 90)\ System.out.println("A");\ else\ if\ (x\ >=\ 80)\ System.out.println("B");\ else\ System.out.println("C");\)?

- **A)** "A"
- **B)** "C"
- **C)** "B", since \(85 \geq 90\) is false, but \(85 \geq 80\) is true, so the second branch executes and the chain stops there
- **D)** Both "A" and "B" are printed

Answer & Explanation:
**Answer: C)**

The chain checks \(x \geq 90\) first (false), then \(x \geq 80\) (true) -- so "B" prints, and the final \(else\) is skipped since a match was already found.
Question #8 Active Recall

Why does the ORDER of conditions matter in a cascading \(if\)-\(else\ if\) chain that assigns letter grades from highest to lowest threshold (90, 80, 70, ...)?

- **A)** Conditions must always be listed in alphabetical order
- **B)** Because only the FIRST true condition's block runs -- if the conditions were instead ordered from LOWEST to HIGHEST threshold, a high score like 95 would incorrectly match the first (lowest) condition it satisfies rather than the intended highest grade
- **C)** The order of conditions in a cascading if-else-if chain never affects the outcome
- **D)** Reordering the conditions would cause a compile-time error

Answer & Explanation:
**Answer: B)**

This is a classic, frequently tested bug: writing grade-threshold conditions from low to high causes every score to match the first, lowest thresh'd condition instead of the correct one.

Want to study all 50 flashcards with spaced repetition?

Practice with Anki-style scheduling, Hands-Free audio commute mode, and AI Tutor explanations.

Start Studying Full Deck Now

How You Can Study This Deck on Chat Robotics

Anki Spaced Repetition (SRS)

Algorithms schedule review intervals automatically so you retain 90%+ in minimum study time.

Hands-Free Audio Commute Mode

High-fidelity Neural Text-To-Speech reads questions and answers aloud with customizable delay timers.

Built-in AI Tutor Assistant

Stuck on a tricky concept? Click "Ask AI" on any card to receive instant deep-dive step-by-step explanations.

Subdeck & Tag Organization

Organize and filter by topic tags or drill entire subdeck hierarchies sequentially in Subdeck Scheduler.