Ap Csa 2020 Frq 1 Gizmo

FRQ Archive2020 FRQs › FRQ 1: Gizmo
2020 AP CSA • ArrayList

AP CSA 2020 FRQ 1: Gizmo

Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF

8 Points Medium Unit 4
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

Download Full FRQ PDF →

PDF cannot display on this device. Open PDF directly →

Timer 22:00

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

Drag corner to expand ▽

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

Drag corner to expand ▽

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;
}
Note on 2020 format: The 2020 exam had a special take-home format due to COVID-19. Part (c) asked students to describe in writing how to add a getCheapestGizmoByMaker method — no code required. Only Parts (a) and (b) required Java code.

Common Mistakes to Avoid

Using == instead of .equals() for Gizmo comparison in Part B

The Gizmo class provides its own equals method. Use purchases.get(i).equals(purchases.get(i+1)).

Loop bound error in hasAdjacentEqualPair

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

The 2020 exam had only 2 questions due to COVID-19. Part (c) required a written class design response, not code.
For hasAdjacentEqualPair, loop bound is purchases.size() - 1 since you access i and i+1.

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.

FRQ Archive →

Related FRQs

ArrayList 2021 FRQ 3: ClubMembers — ArrayList add and backward removal ArrayList 2023 FRQ 3: WeatherData — ArrayList cleaning and heat wave detection

Study the Concepts

Unit 4 Study Guide →

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.0Rating (451+ reviews)
1,845+Verified Hours
54.5%Score 5s

Book a Session ($150/hr) →

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.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]