2005 AP CSA FRQ 1: Hotel
Topic: ArrayList & Object Management
Skills Tested: Array traversal, ArrayList operations, object creation, null checking
Curriculum Alignment: Unit 4 (Data Collections) (2025-2026 AP CSA)
Points: 9 | Time Estimate: ~22 minutes
Part (a)
Write the requestRoom method that assigns a guest to the first available room or adds them to the waitlist.
Solution
public Reservation requestRoom(String guestName)
{
for (int i = 0; i < rooms.length; i++)
{
if (rooms[i] == null)
{
rooms[i] = new Reservation(guestName, i);
return rooms[i];
}
}
waitList.add(guestName);
return null;
}
Part (b)
Write the cancelAndReassign method that cancels a reservation and assigns the room to the first person on the waitlist.
Solution
public Reservation cancelAndReassign(Reservation res)
{
int index = res.getRoomNumber();
if (waitList.size() > 0)
{
String guestName = (String) waitList.remove(0);
rooms[index] = new Reservation(guestName, index);
}
else
{
rooms[index] = null;
}
return rooms[index];
}
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