AP CSA 2015 FRQ 4 Numbergroup
AP CSA 2015 FRQ 4: NumberGroup
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| Question Type | Interface Implementation |
| Key Skills | Write a Range class implementing the NumberGroup interface (contains() checks if a value is within min..max bounds), the |
| Difficulty | Hard |
| AP CSA Units | Unit 3: Class Creation (interface implementation, class design) and Unit 4 (ArrayList of interface-typed objects, composite delegation). |
What This Problem Asks
Write a Range class implementing the NumberGroup interface (contains() checks if a value is within min..max bounds), then write MultipleGroups (holds an ArrayList of NumberGroup objects; contains() returns true if any sub-group contains the value).
Official Question & PDF
PDF cannot display here. Open PDF directly →
Provided Code
public interface NumberGroup
{
boolean contains(int number);
}
// Write the Range class:
// Range(int min, int max) — stores bounds
// contains(int number) — true if min <= number <= max
// Write the MultipleGroups class:
// MultipleGroups(ArrayList groups) — stores groups
// contains(int number) — true if ANY group contains number
Part A — Range class (4 Points)
Write the Range class that implements NumberGroup. Its constructor takes min and max (inclusive bounds); contains() returns true if number is within the range.
Scoring Rubric
| +1 | Declares class with implements NumberGroup |
| +1 | Constructor stores min and max in instance variables |
| +1 | contains() checks number >= min |
| +1 | contains() checks number <= max and returns correct boolean |
Solution
public class Range implements NumberGroup
{
private int minVal;
private int maxVal;
public Range(int min, int max)
{
minVal = min;
maxVal = max;
}
public boolean contains(int number)
{
return number >= minVal && number <= maxVal;
}
}
Part B — MultipleGroups class (5 Points)
Write the MultipleGroups class that implements NumberGroup. Its constructor takes an ArrayList of NumberGroup objects; contains() returns true if any group in the list contains the number.
Scoring Rubric
| +1 | Declares class with implements NumberGroup |
| +1 | Constructor stores the ArrayList of NumberGroup objects |
| +1 | contains() iterates over all groups |
| +1 | contains() calls contains() on each group |
| +1 | Returns true if any group contains the number, false otherwise (algorithm) |
Solution
public class MultipleGroups implements NumberGroup
{
private ArrayList groupList;
public MultipleGroups(ArrayList groups)
{
groupList = groups;
}
public boolean contains(int number)
{
for (NumberGroup g : groupList)
{
if (g.contains(number))
return true;
}
return false;
}
}
Common Mistakes to Avoid
Wrong
return number > minVal && number < maxVal; // excludes boundary values
Correct
return number >= minVal && number <= maxVal; // inclusive bounds
The problem specifies INCLUSIVE bounds. A value equal to min or max IS in the range.
Wrong
public class Range { ... } // missing implements
Correct
public class Range implements NumberGroup { ... }
Both Range and MultipleGroups must declare implements NumberGroup. Without it they do not satisfy the interface and cannot be stored in an ArrayList
Exam Tips
Frequently Asked Questions
What does 2015 AP CSA FRQ 4 NumberGroup ask?
It asks students to write the Range class (implements NumberGroup with inclusive bounds check) and the MultipleGroups class (implements NumberGroup by delegating contains() to a list of NumberGroup objects, returning true if any sub-group matches).
Is interface implementation still tested on the current AP CSA exam?
No. Interfaces and the implements keyword were removed from the AP CSA curriculum in the 2019 redesign. The composite delegation pattern in MultipleGroups is algorithmically interesting but not directly testable on the current exam.
See All 2015 AP CSA FRQs
View the complete 2015 exam hub with solutions, difficulty analysis, and scoring for all four questions.
View 2015 FRQ Hub →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]