---
title: "AP CSA Practice 2: Develop Code Study Guide"
description: "Learn AP Computer Science A Practice 2 Develop Code: write algorithms, data abstractions, and procedural abstractions with worked examples and exam tips."
canonical: "https://fiveable.me/ap-comp-sci-a/computational-thinking-practices/practice-2-develop-code/study-guide/3BHBzxLP089cbwHrKBk0"
type: "study-guide"
subject: "AP Computer Science A"
unit: "Computational Thinking Practices"
lastUpdated: "2026-06-17"
---

# AP CSA Practice 2: Develop Code Study Guide

## Summary

Learn AP Computer Science A Practice 2 Develop Code: write algorithms, data abstractions, and procedural abstractions with worked examples and exam tips.

## Guide

## Overview

[AP Computer Science A](/ap-comp-sci-a "fv-autolink") Practice 2 - Develop Code is the skill of writing and implementing working Java program code. Instead of just reading or analyzing code, you produce it: you translate an [algorithm](/ap-comp-sci-a/key-terms/algorithm "fv-autolink") into syntax, build classes and objects, and call methods to get the result a problem asks for.

This practice shows up everywhere on the exam. It carries an approximate weighting of 22 to 38 percent of the multiple-choice section, and all four free-response questions ask you to write code. If you can develop correct code, you are set up to earn points across the whole test.

## What Practice 2 - Develop Code Means

Develop Code covers three related subskills:

- **2.A** Write program code to implement an algorithm.
- **2.B** Write program code involving data abstractions.
- **2.C** Write program code involving procedural abstractions.

The common thread is production. You are not predicting output (that is Practice 3) or describing behavior (that is Practice 4). You are writing the statements that make a program do what is described.

## What This Practice Requires

Here is what each subskill asks you to do.

**2.A Implement an algorithm**
Turn a described process into code using [sequencing](/ap-comp-sci-a/unit-1/why-programming-why-java/study-guide/lVK6rmrBuug17i1Hna9z "fv-autolink"), [selection](/ap-comp-sci-a/unit-2/algorithms-with-selection-and-repetition/study-guide/42crNSZyW8IRsntk9IHe "fv-autolink"), and iteration.

- Choose the right control structure: `if`, `if-else`, `while`, `for`, or [nested loops](/ap-comp-sci-a/key-terms/nested-loops "fv-autolink").
- Get [loop](/ap-comp-sci-a/key-terms/loop "fv-autolink") [bounds](/ap-comp-sci-a/key-terms/bounds "fv-autolink") and conditions exact so you cover the intended range with no off-by-one errors.
- Combine [Boolean expressions](/ap-comp-sci-a/unit-2/boolean-expressions/study-guide/s6j4i9ram3AlCg3uYjwd "fv-autolink") correctly with `&&`, `||`, and `!`.

**2.B Use data abstractions**
Write code that creates and works with data structures and objects.

- Instantiate objects with the correct [constructor](/ap-comp-sci-a/unit-1/creating-and-storing-objects/study-guide/rUOTKl6Ih5noXJ0GtxJF "fv-autolink") and [argument](/ap-comp-sci-a/key-terms/argument "fv-autolink") types.
- Create and [traverse](/ap-comp-sci-a/key-terms/traverse "fv-autolink") [arrays](/ap-comp-sci-a/unit-4/array-creation-and-access/study-guide/umTe6NA38OqZOhMZjFWi "fv-autolink"), `ArrayList` objects, and 2D arrays.
- Use wrapper classes and `String` methods to store and transform data.

**2.C Use procedural abstractions**
Write code that calls and builds methods.

- Call [instance methods](/ap-comp-sci-a/unit-3/static-variables-and-methods/study-guide/zzhHVbXBRCZQ7ng3EeWX "fv-autolink") on the correct object, and call [static](/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x "fv-autolink") methods on the class.
- Respect access rules: you can call public methods from another class, but not private ones.
- Pass the right number and type of arguments, and use return values correctly.

## Skills You Need for This Practice

You pull from across all four units when you develop code:

- **[Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink"):** declaring [variables](/ap-comp-sci-a/unit-1/expressions-and-assignment-statements/study-guide/01dr6uUPDAn3SjtK2Psr "fv-autolink"), casting, calling `Math` and `String` methods, creating objects.
- **Unit 2:** [Boolean](/ap-comp-sci-a/unit-1/variables-and-primitive-data-types/study-guide/rezA6f3hJz84TKaY5Jjl "fv-autolink") logic, `if-else` chains, `while` and `for` loops, [nested iteration](/ap-comp-sci-a/unit-2/nested-iteration/study-guide/Buapg1KURHNbw6yRY8EZ "fv-autolink").
- **Unit 3:** writing [constructors](/ap-comp-sci-a/unit-3/constructors/study-guide/3Ez6zzak2wRwMrTj2ZQk "fv-autolink"), [accessor methods](/ap-comp-sci-a/unit-3/accessor-methods/study-guide/aGdfIlIw7aOvNseJG5R1 "fv-autolink"), and instance methods inside a class you design.
- **Unit 4:** building and traversing arrays, `ArrayList` objects, 2D arrays, and reading from text files.

Syntax accuracy matters here in a way it does not for analysis questions. A misplaced semicolon or wrong method name means the code will not compile.

## How It Shows Up on the AP Exam

**Multiple choice**
You choose the code segment that correctly fills a `/* missing code */` blank or correctly creates an object.

- 2.A questions ask you to pick the loop header or `if-else` structure that produces a stated result.
- 2.B questions test correct object creation and data structure use.
- 2.C questions test which method call compiles given access modifiers.

**Free response**
All four FRQs assess developing code:

- Question 1: Methods and Control Structures (7 points)
- Question 2: Class Design (7 points)
- Question 3: Data Analysis with `ArrayList` (5 points)
- Question 4: 2D Array (6 points)

You are given the Java Quick Reference, so you do not need to memorize every library method signature.

## Examples Across the Course

**Example 1 (2.A, Unit 2): an if-else chain for year categories**

A method returns "Renaissance" for years 1400 to 1600, "Medieval" for 400 to 1399, and "Other" otherwise. Order and `else if` matter.

```java
if (year > 1600 || year < 400)
{
    category = "Other";
}
else if (year >= 1400)
{
    category = "Renaissance";
}
else if (year >= 400)
{
    category = "Medieval";
}
```

Separate `if` statements without `else` would overwrite earlier correct values, so chaining is the fix.

**Example 2 (2.A, Unit 2): a nested loop that shrinks each row**

To print `0 1 2 3`, then `0 1 2`, then `0 1`, then `0`, the inner loop bound depends on the outer counter.

```java
for (int j = 4; j > 0; j--)
{
    for (int k = 0; k < j; k++)
    {
        System.out.print(k + " ");
    }
    System.out.println();
}
```

**Example 3 (2.B, Unit 1 and 3): creating an object with the right constructor**

Given `public Date(String m, int d)`, only a call with a `String` then an `int` works.

```java
Date birthday = new Date("September", 5);
```

A call like `new Date("September", "5th")` fails because the second argument type is wrong, and you cannot assign to `month` or `day` directly since they are private.

**Example 4 (2.B, Unit 4): building usernames from a text file**

Reading lines like `Cohen-Isabel` and producing `"ICohen"` requires splitting on the dash.

```java
while (scan.hasNext())
{
    String[] temp = scan.next().split("-");
    usernames.add(temp[1].substring(0, 1) + temp[0]);
}
```

Here `temp[0]` is the last name and `temp[1]` is the first name, so you take the first letter of `temp[1]` and join it to `temp[0]`.

**Example 5 (2.C, Unit 3): calling methods with correct access and target**

In a `Duplex` class with two private `Apartment` fields, you call a public method on an object, not on the class, and you cannot reach a private method from outside.

```java
unitOne.calculateRent()  // public, called on an object: works
```

`Apartment.calculateRent()` fails because the method is not static, and `getTenant()` fails because it is private.

## How to Practice Practice 2 - Develop Code

These are practical study suggestions, not official rules.

- Write code by hand or in a plain editor without autocomplete so you catch your own syntax slips.
- For every algorithm, trace your loop bounds with a small input before trusting it.
- Practice object creation by matching constructor parameter types exactly.
- Drill method calls: ask yourself whether the target is an object or a class, and whether the method is public.
- Use full FRQ prompts since all four require you to develop code. Compare your answer to a scoring guide line by line.
- Keep the Java Quick Reference handy while practicing so you learn what is available to you.

## Common Mistakes

- Using separate `if` statements where an `if-else` chain is needed, which lets later conditions overwrite correct answers.
- Off-by-one loop bounds, such as `<=` instead of `<`, that add or drop one iteration.
- Calling a private method from outside its class, or calling an instance method on the class name.
- Passing arguments in the wrong type or order to a constructor.
- Forgetting that `String` methods like `substring` return a new value rather than changing the original.
- Splitting fields incorrectly, for example mixing up `temp[0]` and `temp[1]` after a `split`.

## Quick Review

- Practice 2 means you write and implement code, not just read it.
- **2.A** implements algorithms with selection and iteration.
- **2.B** creates and uses data abstractions like objects, arrays, and `ArrayList` objects.
- **2.C** calls and writes methods while respecting access and static rules.
- This practice covers 22 to 38 percent of multiple choice and appears in all four FRQs.
- Syntax precision, correct loop bounds, correct constructor arguments, and correct method targets are where points are won or lost.
