AP CSA FRQ Guide
2026 FRQ 4: GameBoard
Write the GameBoard method getPointsForRow, which sums the point values of the Space objects in a given row, doubling the sum if every space in that row is the same color.
2D Array22 minute target2D arraysnested loopsconditionalsobject arrays
Skills Tested
What this FRQ is really practicing
2D arraysnested loopsconditionalsobject arrays
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Loop across board[targetRow] to sum every Space object's point value.
- 2While summing, track whether every space in the row shares the same color as the first space.
- 3Return the sum, or two times the sum if every space in the row was the same color.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Comparing colors with == instead of .equals(), which is unreliable for String comparison.
Comparing every space to itself instead of to a fixed reference color captured from the first space in the row.
Doubling the sum unconditionally instead of only when every space matches.
Using board.length (total rows) instead of board[targetRow].length (columns in that specific row) as the loop bound.
Self Check
Review questions before you submit
Iterates across board[targetRow].
Use a loop with board[targetRow].length as the bound.
Adds each space's getPoints() to a running sum.
Call getPoints() on each Space in the row.
Compares each space's getColor() to check whether the whole row matches.
Use .equals(...) to compare color Strings, not ==.
Tracks whether every space so far has matched, e.g. with a boolean flag.
Set a boolean to false as soon as one space has a different color.
Doubles the sum when all spaces in the row are the same color.
Multiply the sum by 2 only inside the all-same-color branch.
Returns the sum (doubled or not).
The method must return an int.
Practice Links
