2004 AP CSA FRQ 2: Pet
Topic: Inheritance & Polymorphism
Skills Tested: Abstract classes, subclass creation, super keyword, method overriding
Curriculum Alignment: Unit 3 (Class Creation) (2025-2026 AP CSA)
Points: 9 | Time Estimate: ~22 minutes
Part (a)
Write the complete Cat class that extends Pet. The speak method returns "meow".
Solution
public class Cat extends Pet
{
public Cat(String name)
{
super(name);
}
public String speak()
{
return "meow";
}
}
Part (b)
Write the complete LoudDog class that extends Dog. The speak method returns the dog sound repeated twice.
Solution
public class LoudDog extends Dog
{
public LoudDog(String name)
{
super(name);
}
public String speak()
{
return super.speak() + super.speak();
}
}
Part (c)
Write the allSpeak method that prints each pet's name followed by its speak output.
Solution
public void allSpeak()
{
for (int i = 0; i < petList.size(); i++)
{
Pet p = (Pet) petList.get(i);
System.out.println(p.getName() + " " + p.speak());
}
}
Key Concepts
Common Mistakes to Avoid
Scoring Guidelines
Total Points: 9
Points are awarded for:
- Correct loop structure and bounds
- Proper method calls and return statements
- Correct conditional logic
- Handling edge cases appropriately
Partial credit is available for demonstrating understanding even with minor syntax errors.
Official College Board Resources
Continue Studying
About the Author: Tanner Crow is a certified AP Computer Science teacher with 11+ years of experience helping students succeed on the AP CSA exam.
Last updated: January 2026