Privacy note: We capture your IP address to provide customised and focused services. See our Privacy Policy.

AP Computer Science A: Deep Dive and FRQ Mastery — Alpha School

Lesson 19: Writing Strong FRQs — Methods, Classes and the AP Rubric

The free-response section asks you to write Java code, and it is marked against a rubric that awards points for specific pieces of correct behaviour, not for a general impression. Each question is broken into small, checkable parts — a point for the correct method header, a point for the loop, a point for the condition, a point for the return value — and the marker awards each point independently. That structure is good news: even a partial answer earns partial credit, and a small error in one part does not destroy the rest. The strategy is to earn every point you can, one piece at a time.

The most common way to lose points is a method that does not match the question's specification. Read the question twice before writing anything, and underline the method name, the parameter types, the return type, and any conditions on the behaviour. Then write the header exactly as specified: a method that takes an int[] but is written to take an ArrayList will not compile as asked, and the rubric cannot award points for it. If the question says the method must not modify its parameter, do not modify it; if it says to assume a precondition, such as a non-empty array, you may rely on it and need not check for it.

Inside the method, the rubric rewards the standard patterns you have practised all course: a traversal with the correct bounds, a condition that tests the right thing, an accumulator started at the right value, and a return on every path. The most frequent errors are off-by-one loop bounds, comparing Strings with ==, forgetting to return a value, and returning inside a loop when the return belongs after it. A useful habit is to write the skeleton first — the header, the loop, the return — and then fill in the body, checking each line against the question as you go. If you run out of time, a skeleton with the right structure still earns some points.

Finally, remember that the rubric is about behaviour, not style: a solution that works but is inelegant earns full credit, while a beautiful solution that fails on an edge case loses the points for that case. Test your method mentally on the smallest inputs — an empty array, a single element, the value at the boundary — because those are the cases the rubric's test data will include. And if you cannot remember a method name exactly, write the closest correct code you can: a method that is almost right earns more than a blank, and a blank earns nothing.

Markers read your code, not your intentions, so clarity is part of the answer even though the rubric does not award points for style. Use the names the question uses for parameters and variables, because a marker checking your work against the question will find them faster, and keep your indentation consistent so the structure of the code is visible. A short comment explaining an unusual step — why a loop starts at 1, or why a value is initialized the way it is — can prevent a marker from misreading a correct line as an error. Finally, if you are unsure between two ways of writing something, choose the one you have practised most, because familiar code is the code you are least likely to get wrong under pressure.

A worked example

Worked example: a question asks for a method countEven that takes an int[] and returns how many of its elements are even. A complete answer earns points for the header, the traversal, the even test, and the return — and the version below shows each piece in its simplest correct form.

public int countEven(int[] data)
{
    int count = 0;
    for (int i = 0; i < data.length; i++)
    {
        if (data[i] % 2 == 0)
        {
            count++;
        }
    }
    return count;
}
// countEven({1, 2, 3, 4}) returns 2

The header matches the specification exactly, the loop runs from 0 to data.length − 1, the condition data[i] % 2 == 0 tests evenness, the accumulator starts at 0, and the return sits after the loop so every element is counted. A version that returned inside the loop would stop after the first element, and a version that started count at 1 would be one too large — both are errors the rubric would catch. When you finish a method, trace it on a two-element array by hand: if it works there, it usually works everywhere.

Key Terms

Rubric
The marking scheme awarding points for specific correct pieces of an answer.
Specification
The exact method header and behaviour a question asks for.
Precondition
A condition the question guarantees, which your code may rely on without checking.
Edge case
An extreme or boundary input, such as an empty array, that tests whether code is fully correct.

Discussion Questions

  1. Why is a partial answer worth writing, even if you cannot finish the method?
  2. What should you check first when you read a free-response question?
  3. Why does the rubric test edge cases such as an empty array?

Practice Questions

  1. A question asks for a method named total that takes an ArrayList<Integer> and returns an int. Write its header.
  2. A method returns inside its loop. What goes wrong?
  3. Why should you use data.length rather than a number as a loop bound in a free-response answer?
  4. A question guarantees the array is non-empty. Do you need to check for an empty array?
  5. Name two errors that commonly lose rubric points in free-response methods.
Show answers
  1. public int total(ArrayList<Integer> list)
  2. It stops after the first iteration, so only the first element is processed.
  3. Because the rubric's test data may use an array of a different size.
  4. No; you may rely on the stated precondition.
  5. Any two of: wrong method header, off-by-one loop bounds, comparing Strings with ==, missing return, returning inside a loop.
Keep reading to complete this lesson