2010 AP CSA FRQ 2: APLine
Topic: Complete Class Design
Skills: Class implementation, constructor, accessor methods, mathematical calculations
Unit: Unit 3 (Class Creation) (2025-2026 AP CSA)
Points: 9 | Time: ~22 minutes
Part (a)
Write the complete APLine class representing a line ax + by + c = 0.
Solution
public class APLine
{
private int a, b, c;
public APLine(int a, int b, int c)
{
this.a = a;
this.b = b;
this.c = c;
}
public double getSlope()
{
return -a / (double) b;
}
public boolean isOnLine(int x, int y)
{
return a * x + b * y + c == 0;
}
}Part (b)
Note: This was a single-part question requiring the complete class.
Solution
// Key insight: DO NOT store slope as instance variable
// Calculate it from a and b when needed
// Cast to double to avoid integer divisionKey Concepts
Common Mistakes
Official Resources
Author: Tanner Crow - AP CS Teacher, 11+ years