AP CSA FRQ Guide

2016 FRQ 2: LogMessage

Parse log messages into machine and description fields, detect a whole word in a description, and remove matching messages from a system log.

String Parsing and ArrayList Removal22 minute targetStringsubstringindexOfArrayListremoval

Skills Tested

What this FRQ is really practicing

StringsubstringindexOfArrayListremoval

Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.

Starter Approach

How to begin without copying a solution

  1. 1Constructor: split at the colon and store the two parts.
  2. 2containsWord: find whole-word matches, not just substrings.
  3. 3removeMessages: mutate the log list while preserving removed messages.

Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.

Common Mistakes

Mistakes to watch for while writing

Counting a keyword that appears as part of a larger word.
Skipping the item after a removal in a forward loop.
Forgetting to add removed messages to the result list.

Self Check

Review questions before you submit

Splits the message at the colon.

indexOf(":") followed by substring is a common approach.

Checks word boundaries around the keyword.

A keyword inside another word should not count.

Removes matching messages without skipping elements.

Loop backward or adjust the index after removal.

Returns a list containing the removed messages.

The method should not only delete items; it also returns what was removed.

Practice Links

Where to go next