AP CSA 2014 FRQ 3 Seatingchart

FRQ Archive2014 FRQs › FRQ 3: SeatingChart
2014 AP CSA • Class Writing

AP CSA 2014 FRQ 3: SeatingChart

Complete solution, scoring rubric, and walkthrough — verified from the official College Board PDF

9 Points Medium Class Writing Classic Format (Pre-2019)
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

Download Full 2014 FRQ 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() { ... }
Timer 22:00

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).

Drag corner to expand ▽

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(ArrayList studentList, 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++;
            }
        }
    }
}
Use a single index variable that increments each time a student is placed. The guard condition studentIndex < studentList.size() prevents going out of bounds. Remaining cells default to null automatically.

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).

Drag corner to expand ▽

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;
}
Guard against null slots with seats[row][c] != null before calling isAbsent(). Calling isAbsent() on null throws a NullPointerException.

Common Mistakes to Avoid

Going out of bounds on studentList

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.

Calling isAbsent() on null slots

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

The index variable pattern (single int tracking ArrayList position) is reusable for any 2D fill from a 1D source.
This FRQ is directly applicable to the current exam — 2D array construction from a list is a classic FRQ 4 pattern.

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.

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]