AP CSA 2014 FRQ 3 Seatingchart
AP CSA 2014 FRQ 3: SeatingChart
Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF
| Question Type | Class Writing |
| Key Skills | Write the SeatingChart constructor (fill a 2D Student array from an ArrayList of students, row by row, leaving empty slo |
| Difficulty | Medium |
| AP CSA Units | Unit 4: Data Collections (2D array construction from ArrayList, row traversal) and Unit 3: Class Creation (constructor with 2D array field). |
What This Problem Asks
Write the SeatingChart constructor (fill a 2D Student array from an ArrayList of students, row by row, leaving empty slots as null if the list runs out) and countAbsentInRow() (count students in a given row whose isAbsent() returns true).
Official Question & PDF
PDF cannot display here. Open PDF directly →
Provided Code
public class SeatingChart
{
private Student[][] seats;
public SeatingChart(ArrayList studentList, int rows, int cols)
{ /* to be implemented in part (a) */ }
public int countAbsentInRow(int row)
{ /* to be implemented in part (b) */ }
}
// Student class (provided):
// public boolean isAbsent() { ... }
Part A — SeatingChart constructor (6 Points)
Write the constructor. Fill the 2D seats array row by row from studentList. If the list is exhausted before the array is full, remaining slots are null (Java default).
Scoring Rubric
| +1 | Creates seats as a new 2D array of size rows x cols |
| +1 | Uses a variable to track the current position in studentList |
| +1 | Fills seats in row-major order (row by row) |
| +1 | Stops filling when studentList is exhausted |
| +1 | Does not go out of bounds on studentList |
| +1 | Correctly maps list index to 2D position (algorithm) |
Solution
public SeatingChart(ArrayListstudentList, int rows, int cols) { seats = new Student[rows][cols]; int studentIndex = 0; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { if (studentIndex < studentList.size()) { seats[r][c] = studentList.get(studentIndex); studentIndex++; } } } }
Part B — countAbsentInRow (3 Points)
Write countAbsentInRow(). Count and return the number of absent students in the given row. Null slots should not be counted (guard against NullPointerException).
Scoring Rubric
| +1 | Accesses all columns in the given row |
| +1 | Calls isAbsent() to check each student |
| +1 | Returns correct count (algorithm) |
Solution
public int countAbsentInRow(int row)
{
int count = 0;
for (int c = 0; c < seats[row].length; c++)
{
if (seats[row][c] != null && seats[row][c].isAbsent())
{
count++;
}
}
return count;
}
Common Mistakes to Avoid
Wrong
seats[r][c] = studentList.get(studentIndex++); // throws if list exhausted
Correct
if (studentIndex < studentList.size()) {
seats[r][c] = studentList.get(studentIndex++);
}
If the list has fewer students than grid cells, get() on an out-of-range index throws IndexOutOfBoundsException. Always check studentIndex < studentList.size() before accessing.
Wrong
if (seats[row][c].isAbsent()) // NullPointerException if slot is null
Correct
if (seats[row][c] != null && seats[row][c].isAbsent()) // null guard first
When the list doesn't fill the grid, some seats are null. Calling any method on null throws NullPointerException. Always check != null first.
Exam Tips
Frequently Asked Questions
What does 2014 AP CSA FRQ 3 SeatingChart ask?
It asks students to write the SeatingChart constructor, which fills a 2D Student array row by row from an ArrayList (stopping if the list runs out), and countAbsentInRow(), which counts absent students in a given row while guarding against null slots.
Why must countAbsentInRow check for null?
If the student list had fewer students than grid cells, the remaining slots are null (Java default for reference types). Calling isAbsent() on a null reference throws a NullPointerException. The null check must come before the method call using short-circuit &&.
See All 2014 AP CSA FRQs
View the complete 2014 exam hub with solutions, difficulty analysis, and scoring for all four questions.
View 2014 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]