Ap Csa 2020 Frq 1 Gizmo
AP CSA 2020 FRQ 1: Gizmo
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| Question Type | ArrayList |
| Skills Tested | ArrayList traversal, compound boolean conditions, object equals method, adjacent-pair pattern |
| Difficulty | Medium |
| Recommended Time | 22 minutes |
What This Problem Asks
2020 AP CSA FRQ 1 (Gizmo/OnlinePurchaseManager) was part of the special COVID take-home exam. countElectronicsByMaker counts items that are electronic AND from the specified maker. hasAdjacentEqualPair detects whether any two adjacent items in the purchases list are equivalent using the Gizmo’s own equals method.
What This FRQ Tests
This FRQ tests Unit 4: ArrayList traversal and Unit 2 (compound conditions with &&, indexed loops for adjacent comparison).
Official Question & PDF
PDF cannot display on this device. Open PDF directly →
Provided Code
public class Gizmo
{
public String getMaker() { /* not shown */ }
public boolean isElectronic() { /* not shown */ }
public boolean equals(Object other) { /* not shown */ }
}
public class OnlinePurchaseManager
{
private ArrayList purchases;
/** Returns count of electronic Gizmos from the given maker. */
public int countElectronicsByMaker(String maker) {
/* part (a) */
}
/** Returns true if any two adjacent Gizmos in purchases are equivalent. */
public boolean hasAdjacentEqualPair() {
/* part (b) */
}
}
Part A — 4 Points
Write countElectronicsByMaker: examine purchases and return the number of Gizmo objects that are both electronic (isElectronic() is true) and manufactured by maker.
Write Your Solution
Scoring Rubric (Part A — 4 points)
| +1 | Traverses the purchases ArrayList |
| +1 | Calls isElectronic() on a Gizmo object |
| +1 | Calls getMaker() and compares to maker using equals
|
| +1 | Returns count of matching Gizmos (electronic AND matching maker) |
Solution
public int countElectronicsByMaker(String maker)
{
int count = 0;
for (Gizmo g : purchases)
{
if (g.isElectronic() && g.getMaker().equals(maker))
{
count++;
}
}
return count;
}
Part B — 4 Points
Write hasAdjacentEqualPair: return true if any two adjacent Gizmo objects in purchases are equivalent (using the equals method of Gizmo). Return false if no adjacent equal pair exists or if purchases has fewer than 2 elements.
Write Your Solution
Scoring Rubric (Part B — 4 points)
| +1 | Traverses adjacent pairs in purchases
|
| +1 | Calls equals on a Gizmo object to compare adjacent elements |
| +1 | Returns true when an adjacent equal pair is found |
| +1 | Returns false when no adjacent equal pair found (or fewer than 2 elements) |
Solution
public boolean hasAdjacentEqualPair()
{
for (int i = 0; i < purchases.size() - 1; i++)
{
if (purchases.get(i).equals(purchases.get(i + 1)))
{
return true;
}
}
return false;
}
getCheapestGizmoByMaker method — no code required. Only Parts (a) and (b) required Java code.Common Mistakes to Avoid
The Gizmo class provides its own equals method. Use purchases.get(i).equals(purchases.get(i+1)).
The loop must stop at purchases.size() - 1 (exclusive) since you compare i with i+1. Going to purchases.size() causes IndexOutOfBoundsException on the last iteration.
Exam Tips
Scoring Summary
| Part | Method | Points |
|---|---|---|
| Part A | Write |
4 |
| Part B | Write |
4 |
| Total | 8 |
Want the Complete 2020 FRQ Solutions?
Browse all past AP CSA FRQs with full solutions and scoring breakdowns.
Related FRQs
ArrayList 2021 FRQ 3: ClubMembers — ArrayList add and backward removal ArrayList 2023 FRQ 3: WeatherData — ArrayList cleaning and heat wave detectionStudy the Concepts
Struggling with FRQs? Get 1-on-1 Help
Work directly with Tanner — AP CS teacher with 11+ years experience and 1,845+ verified tutoring hours. 54.5% of students score 5s (vs. 25.5% national average).
5-session packages at $125/hr. Venmo, Zelle, PayPal, or credit card.
Frequently Asked Questions
What was the 2020 AP CSA exam format?
The 2020 AP Computer Science A exam was a special take-home exam due to COVID-19. It had only 2 questions (vs the usual 4), each with code-writing parts (a) and (b) and a written design part (c). The exam was submitted digitally.
What does 2020 AP CSA FRQ 1 Gizmo test?
FRQ 1 tests ArrayList traversal with compound conditions (isElectronic AND matching maker), adjacent-pair comparison using the object's own equals method, and written class design.
How many points is 2020 FRQ 1 worth?
Part a is 4 points, Part b is 4 points. Part c was a written design question worth additional points under the special 2020 format.
Why use g.equals() instead of == in hasAdjacentEqualPair?
The Gizmo class provides its own equals method that defines what 'equivalent' means for Gizmo objects. Using == would compare object references, not equivalence as defined by the class.
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]