2013 AP CSA FRQ 1: MusicDownloads - Solution

2013 AP CSA FRQ 1: MusicDownloads

Topic: ArrayList & Object Tracking

Skills: ArrayList operations, object lookup, accumulator pattern

Unit: Unit 4 (Data Collections) (2025-2026 AP CSA)

Points: 9 | Time: ~22 minutes

Part (a)

Write the getDownloadInfo method that finds a download by title.

Try First! Attempt before viewing solution.

Solution

public DownloadInfo getDownloadInfo(String title)
{
    for (DownloadInfo d : downloadList)
    {
        if (d.getTitle().equals(title))
        {
            return d;
        }
    }
    return null;
}

Part (b)

Write the updateDownloads method that updates or adds download info.

Solution

public void updateDownloads(List titles)
{
    for (String title : titles)
    {
        DownloadInfo info = getDownloadInfo(title);
        if (info == null)
        {
            downloadList.add(new DownloadInfo(title));
        }
        else
        {
            info.incrementTimesDownloaded();
        }
    }
}

Key Concepts

✓ Use helper method when provided (getDownloadInfo)
✓ null check before using returned object
✓ Create new object if not found
✓ Modify existing object if found

Common Mistakes

Not using the getDownloadInfo helper method
NullPointerException from not checking null
Creating duplicate entries
Not incrementing for existing downloads
Practice Similar: 2019 FRQ 3 | 2021 FRQ 3 | 2023 FRQ 3

Official Resources

Author: Tanner Crow - AP CS Teacher, 11+ years

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]