AP Computer Science A

View original course

58 study materials · 60 sections

AP Computer Science A students working the current College Board Course and Exam Description, including first-time students with no prior background, plus teachers reviewing the page for CED alignment.; Teach every official CED unit and every numbered topic at topic granularity.; Develop every AP skill / science-practice code explicitly and by name.; Replace description with teaching: worked contextual examples, named misconceptions, and in-flow retrieval checks.; Build an exam-practice unit covering every task type on the current exam.

Course Sections

Course Framework, Skills and Reasoning Processes

Key concepts: AP course alignment with college-level curricula · Course Framework organization of content and skills into units · Formative assessment through AP Classroom Progress Checks · AP Course Audit requirements · Use of AP Classroom reports and Question Bank · Access to computers and the internet for AP Computer Science A · Independent time for students to develop solutions · AP Computer Science A exam weighting by unit · Code-based reasoning and debugging procedural errors · Connecting programming assignments to student interests

AP Computer Science A is an introductory college-level study of Java programming, object-oriented design, algorithms, data structures, testing, and responsible computing. AP courses are intended for willing, academically prepared students who may earn college credit, advanced placement, or both by demonstrating…

1.1 Introduction to Algorithms, Programming, and Compilers

Key concepts: Algorithms as step-by-step procedures for solving problems · Program design and expressing solutions precisely in Java · Testing programs and identifying and correcting errors · Comparing alternative solutions to the same problem · Compilers and the translation of Java source code · Sorting algorithms · Kinesthetic learning through physically arranging students in sorted order · Collaborative and individual problem-solving in laboratory activities

An algorithm is a finite, ordered set of instructions that accomplishes a specific task. A recipe, a route-finding procedure, and a Java program can all be algorithms when their steps are precise enough to follow and eventually stop.

1.2 Variables and Data Types

Key concepts: Java programming language · Variables · Classes · Data types · Primitive types · int values · double values · Sequential flow · Data abstractions · Compilation and code errors

A Java program becomes useful when it can remember information: a score, a temperature, a button’s state, or the name of a player. A variable is a named storage location whose value can be used while a program executes.

1.3 Expressions and Output

Key concepts: Expressions and output · System.out.println and println · String concatenation in output · Method specifications · Conditional statements · Iterative statements · String substring bounds · Self-pairing guards · Array or grid row-and-column indexing · List size and object equality checks

An expression produces a value, and an output statement displays that value so a person can observe what the program calculated. In Java, System.out.println displays information and then moves the cursor to a new line; System.out.print displays information but leaves the cursor on the same line.

1.4 Assignment Statements and Input

Key concepts: Assignment operators and assignment statements · Expressions and typed values · Input and developing code to receive input · String manipulation and searching with indexOf() · Helper method calls for modular code · Conditional if-else if-else statements · Boolean expressions and comparisons · Incrementing variables in iterative logic · 2D arrays and grid-based movement · Toggling between two states

A program changes the world it models by assigning new values to variables and receiving values from outside the program. A temperature-monitoring program, for example, must read each temperature, store it, test it, and update a count when a heat wave continues.

1.5 Casting and Range of Variables

Key concepts: Casting double values to int in Java · Generating random integers with Math.random() · Converting a random decimal to a bounded integer range · Inclusive integer ranges · Uniform random-number generation · Calculating 5% and 95% probabilities · Using conditional logic for probabilistic outcomes · Guarding against negative variable values

Java’s Math.random() produces a decimal, but many programs need a whole-number outcome—such as a die roll, a temperature category, or a bird’s daily food consumption.

1.6 Compound Assignment Operators

Key concepts: Compound assignment operators · Assignment statements · Determining the value stored in a variable · Step-by-step changes to variable values · Operator precedence · Multiplication, division, and remainder precedence over addition and subtraction

A statement such as score += 10; does two jobs at once: it calculates a new value from the current score, then stores that result back in score.

1.7 Application Program Interface and Libraries

Key concepts: Application Program Interface (API) and libraries · Classes defined by an API · Reference types · Attributes and behaviors of API classes · Method signatures · Calling instance methods · String literals · Determining the result or output of code · Identifying why a code segment will not compile or work as intended · Describing the behavior of a code segment or program

An application programming interface (API) is a documented set of classes and methods that lets a programmer use existing software without knowing how that software was implemented.

1.8 Documentation with Comments

Key concepts: Documentation comments in Java · Javadoc-style method and constructor specifications · Preconditions · Postconditions · Method contracts · Documenting parameters and return values

A Java comment can explain what a method expects and guarantees without changing a single step of program execution. Good documentation acts like a contract between a method and its caller: before calling, the caller must satisfy certain conditions; after the method finishes, the method promises certain results.

1.9 Method Signatures

Key concepts: Class design using attributes and behaviors · Method signatures and corresponding method descriptions · File object construction with a pathname · Two-dimensional array indexing by row and column · Writing methods that process a specified row · Summing point values across a row · Constructors and object initialization · Accessor and mutator methods such as getSignature and addSignature · Using method calls to test expected behavior · Handling distinct cases in method implementations

A method’s signature is its identity at the call boundary: the method name together with its parameter types. Before writing a class, design its attributes—the data it stores—and behaviors—the operations it performs—using natural language, a sketch, or a class diagram.

1.10 Calling Class Methods

Key concepts: Calling class methods · Class methods are associated with the class rather than an individual object · Using Math class methods · Using String class methods · Creating String objects · Combining strings · Determining the result of a method call · Recognizing code that will not compile · String objects as sequences of characters · The scope limitation on overriding toString

A class method is called through a class name because it belongs to the class itself, not to any particular object. In Java, the call Math.max(8, 13) asks the Math class to perform an operation; no individual Math object is needed.

1.11 Math Class

Key concepts: Java Math class · Absolute value with Math.abs · Integer arithmetic using Math.abs(int) · Decimal arithmetic using Math.abs(double) · Exponentiation using Math.pow · Square roots using Math.sqrt

A robot measuring a package may need the distance from a target, the area of a panel, or the square root of a sensor reading; Java’s Math class supplies these operations as ready-to-use static methods.

1.12 Objects: Instances of Classes

Key concepts: Objects · Classes · Instances · Attributes · Relationship between a class and an object · Class as a blueprint for modeling

A class describes what a kind of thing is; an object is one specific thing made from that description. A Monster class might define that every monster has a color, a number of eyes, and a name, while each individual monster has its own particular values for those attributes.

1.13 Object Creation and Storage

Key concepts: Object creation and storage (instantiation) · Constructors · Constructor names matching class names · Constructor signatures · Overloaded constructors · Reference-type variables · The new keyword · Calling a class constructor · Adding a newly created object to an ArrayList · Using the remainder operator (%)

A Java variable of a reference type does not contain an object directly; it holds a reference to an object, or the special value null when it refers to no object.

1.14 Calling Instance Methods

Key concepts: Calling instance methods on objects · Using instance variables, parameter variables, and local variables as method-call receivers · Calling methods on the current object · Calling methods on an object from a different class · Passing parameters when calling methods · Distinguishing void methods from methods that return a value · Using method calls in conditional statements and loops · Comparing values returned by method calls · Using compound conditional expressions for ranges · Accumulating values returned or calculated by method calls

An instance method is called through a particular object, because its behavior may depend on that object’s instance variables. The receiver—the object on which the method operates—can be stored in an instance variable, parameter variable, or local variable.

1.15 String Manipulation

Key concepts: String prefix matching · The indexOf method · The substring method · String traversal in a list · Handling no-match, match-start, and match-end cases · Building a result list without modifying the original list · Comparing current and previous strings · String algorithm implementation

A string is a sequence of characters whose positions begin at index $0$, so finding a word inside another string is an exercise in locating boundaries precisely.

2.1 Algorithms with Selection and Repetition

Key concepts: Algorithms · Sequencing · Selection · Repetition · Iteration · Decision making · Conditional statements · while loops · for loops · Algorithm control flow

An algorithm is a precise sequence of steps for solving a problem or producing an outcome. Algorithms use sequencing, and may also use selection and repetition, depending on the problem: a recipe can be sequencing alone, while a traffic-control system may repeatedly check conditions and choose different actions.

2.2 Boolean Expressions

Key concepts: Boolean literals and return values · Logical AND operator (&&) · Logical NOT operator (!) · Relational and equality comparisons · Compound Boolean expressions · Short-circuit evaluation of Boolean conditions · Finding contiguous blocks through iteration · Tracking block length with a counter · Returning a sentinel value when no block is found · Common loop-structure and variable-initialization errors

A Boolean expression evaluates to exactly one of two values: true or false. That simple choice controls whether an algorithm accepts a match, continues searching, reserves time, or reports failure.

2.3 if Statements

An if statement lets a Java program choose whether to execute a block of code. It is the basic mechanism behind decisions such as approving a loan, displaying a warning, or recommending a school club.

2.4 Nested if Statements

Key concepts: Nested if statements · Logical equivalence of nested conditions and the || operator · Equality comparison using == · Conditional logic · Two-dimensional array element assignment · Identifying pairs of elements · Iteration · Counting algorithms · Sequential if statements · Combining conditions with logical operators

A nested if statement places one conditional statement inside another, allowing a program to test a second condition only after a first condition succeeds. This creates a decision structure like a security checkpoint: first verify that a person has a ticket, then—only for ticket holders—check whether the ticket is…

2.5 Compound Boolean Expressions

Key concepts: Compound Boolean expressions · Logical AND operator (&&) · Logical OR operator (||) · else if structures · Boolean expression evaluation · Conditional statements · Algorithm implementation · Determining program output · Guess-checker algorithms · Counting correct digits in correct locations

A compound Boolean expression combines two or more Boolean conditions into one expression that evaluates to either true or false. In Java, logical operators let one conditional statement express several acceptable or required situations at once.

2.6 Comparing Boolean Expressions

Key concepts: Equivalent Boolean expressions · Comparing Boolean expressions · De Morgan’s laws · Logical negation with ! · Logical OR (||) · Logical AND (&&) · Comparing object references · The equals method · Boolean expressions in conditional statements · Determining results from statement execution order

Two Boolean expressions are equivalent when they produce the same Boolean result in every possible case, even if their symbols and structure look different. The practical payoff is powerful: you can replace a complicated condition with a clearer one without changing the program’s behavior.

2.7 while Loops

Key concepts: while-loop syntax and condition evaluation · compound loop conditions using && and || · counter-controlled loops · sentinel conditions and loop termination · updating loop-control variables · simulating repeated days with a while loop · returning the number of completed iterations · accumulating values while traversing a 2D array · updating row and column positions from a Location · avoiding skipped elements when shifting items during traversal

A Java while loop repeats a block of code as long as its Boolean condition remains true. Unlike a for loop, which places initialization, continuation, and update expressions together, a while loop makes the stopping logic explicit—useful when repetition depends on a changing resource, a sentinel value, or a…

2.8 for Loops

Key concepts: for-loop syntax and iteration · nested for loops · row-major and column-major traversal of 2D arrays · enhanced for loops · array modification limitations with enhanced for loops · loop counters and accumulator variables · variable scope within curly-brace blocks · loop initialization and termination conditions · traversing ArrayLists with for loops · using loops to search and update array elements

A for loop is a compact way to repeat an action while a counter moves through a predictable range. Its three-part header answers three questions in order: Where does the counter start?

2.9 Implementing Selection and Iteration Algorithms

Key concepts: Selection algorithms · Iteration algorithms · Implementing algorithms in program code · for loops · while loops · Equivalence between for loops and while loops · AP Computer Science A Unit 2: Selection and Iteration · Suggested Skill 2.A · Suggested Skill 3.A · Suggested Skill 4.A

A useful algorithm is more than a clever idea: it is a sequence of instructions that makes a decision, repeats a process, or both. In Java, selection chooses among paths of execution, while iteration repeats a block of code until a condition or counting rule says to stop.

2.10 Implementing String Algorithms

Key concepts: Procedural abstractions and method implementation · Conditional statements using if-else · Boolean comparisons such as whosActive == true · String concatenation with the + operator · Producing output with System.out.print · Processing ArrayList<String> data · Accessing adjacent list elements with get(i) and get(i + 1) · Determining program output from code · Identifying and correcting compilation or logic errors

A string algorithm treats text as data: it can inspect characters, compare words, join pieces, search for a substring, or produce a new text value.

2.11 Nested Iteration

Nested iteration places one loop inside another, allowing a program to repeat an entire sequence of actions for every pass of an outer loop. It is the natural tool for processing grids, tables, schedules, and every pair of items in a collection.

2.12 Informal Run-Time Analysis

Key concepts: Statement execution count · Informal run-time analysis · Tracing code · Analysis of iterative statements · Selection and iteration · Describing the behavior of a code segment or program · Unit 2 concepts

A statement execution count is the number of times a particular statement runs while a program executes. Counting executions gives us a practical way to estimate how much work a program performs without measuring seconds on a specific computer.

3.1 Abstraction and Program Design

Key concepts: Abstraction · Data abstraction · Attributes · Program design · Design Code phase · Develop Code phase · Analyze Code phase · Document Code phase · Parameters and parameterization · Iterative program development

A well-designed program does not expose every detail at once: it presents the important idea and hides the machinery that makes it work. Abstraction is this reduction of complexity by focusing on the main idea while leaving irrelevant details out of view.

3.2 Impact of Program Design

Key concepts: Impact of program design · Computing’s impact on society, economy, and culture · Ethical programming and AI use · Programming failures and their consequences · Positive and negative effects of code on communities · AP Computer Science A Unit 3: Class Creation · Skill 5.A · Requirement tag CR7 · Designing, writing, and testing Java programs · Intergalactic Calculations lab

A program is never only code: once people use it, its design can change decisions, opportunities, costs, and culture. 3.2 Impact of Program Design asks the central question: What happens to people and communities when a computing system works—or fails—in the real world?

3.3 Anatomy of a Class

Key concepts: Visual relationship between the Learning Objective and Essential Knowledge points · Learning Objective 3.2.A · Explaining social and ethical implications · Essential Knowledge points 3.2.A.1, 3.2.A.2, and 3.2.A.3 · System reliability · Societal impacts · Intended impacts · Unintended impacts

A reliable computing system can affect people far beyond the code that runs it, so evaluating a program requires more than asking whether it produces the intended output.

3.4 Constructors

A constructor is the code that gives a newly created object its initial state. When a program creates a Book, the constructor can ensure that the book begins with a title, an author, and a valid page count instead of existing as an uninitialized bundle of data.

3.5 Methods: How to Write Them

Key concepts: Method signatures and parameters · Return statements and flow of control · Writing program code to call methods · Writing methods to satisfy specifications · Using expressions and conditional statements in methods · Predicting and comparing method output · Explaining and correcting compilation or logic errors · Creating classes with constructors and instance variables · Maintaining object state across method calls · String manipulation and substring operations

A method is a named block of Java code that performs a task and optionally sends a value back to the statement that called it.

3.6 Methods: Passing and Returning References of an Object

Key concepts: Java uses pass-by-value for method arguments · Object references are values that can be copied when passed to methods · A copied reference can still refer to the same mutable object · Methods can modify the state of a mutable object through a reference parameter · Reassigning a reference parameter does not change the caller’s reference · Returning an object reference can give the caller access to the existing object rather than a new copy · A reference variable and the object it refers to are distinct · A reference may hold null · Private data and methods of a referenced parameter cannot be accessed directly outside its class · Enhanced for-loop variables do not change the corresponding values in the collection when reassigned

Java passes every method argument by value. For an object, that value is not the entire object—it is a reference, a value that identifies where the object can be found.

3.7 Class Variables and Methods

Key concepts: Class variables (static variables) · Class methods (static methods) · Accessing static members with the class name and dot operator · Difference between class members and instance members · Accessor methods · Mutator (modifier) methods · The final modifier · Methods as behaviors of a class · Variables storing object data · Class structure: header, instance variables, constructors, and methods

A class variable belongs to the class itself, so every object created from that class shares one stored value. An instance variable, by contrast, belongs to one particular object.

3.8 Scope and Access

Key concepts: Scope and access of variables · Variables declared in block headers or bodies · Local variables · Block-level visibility · Accessing variables only within their declaring block

A variable is usable only inside the region of code where its declaration is visible. That region is its scope: the part of a program in which a variable can be referred to by name.

3.9 this Keyword

Key concepts: Java instance variables · private access modifier · static versus instance variables · constructors · constructor header syntax · block structure and indentation · return statements · grid and Location handling

Java uses the keyword this to identify the object whose instance method or constructor is currently running. That single reference becomes especially useful when a class contains fields and parameters with the same names.

4.1 Ethical and Social Issues Around Data Collection

Key concepts: Personal privacy risks from collecting and storing data · Safeguarding user privacy in program development · Data quality · Algorithmic bias · Systemic and repeated errors that create unfair outcomes · Bias and fairness in data sets · Selecting an appropriate data set for a problem · Ethical and social implications of computer science · Responsible computing · Discussing ethical issues in groups

When a computer collects, stores, or uses personal information, privacy can be harmed even when no single programmer intends to cause harm. A fitness app, for example, might record a person’s location, sleep schedule, heart rate, and daily routines; together, these details can reveal far more than any one data point.

4.2 Introduction to Using Data Sets

Key concepts: Data sets can be manipulated and analyzed to solve problems or answer questions · Determining what knowledge can be extracted from data · Contextual relevance of data and the validity of data for a specific problem · Algorithmic bias and strategies to identify and mitigate it · Using arrays and 2D arrays to represent data · Traversing a list from both ends · Handling even- and odd-sized data sets with conditional logic · Creating objects from data and storing them in an ArrayList · Initializing accumulators before loops · Avoiding redundant method calls in loops

A data set is a collection of specific pieces of information that can be examined one value at a time to answer a question or solve a problem.

4.3 Array Creation and Access

Key concepts: One-dimensional and two-dimensional array creation · Two-dimensional array initializer lists · Array indexing and element access · Row-and-column indexing convention · Array element modification · Avoiding array out-of-bounds errors · Traversing arrays with loops · Accessing all elements of an array · Computing values from array elements · Method implementation using arrays

An array is a fixed-size sequence whose elements are accessed by position, and a two-dimensional array extends that idea by organizing elements into rows and columns.

4.4 Array Traversals

Key concepts: Array traversals · For loops · Writing a for-loop header · Modifying code to correct errors

An array traversal visits array elements one at a time, usually by moving an index from the first valid position to the last. A for loop is the most compact Java tool for expressing that repeated movement.

4.5 Implementing Array Algorithms

Key concepts: Implementing algorithms that operate on one-dimensional arrays · Traversing array elements with loops · Using array indices to access and update elements · Searching an array for a target value · Computing aggregate results such as sums, counts, minimums, and maximums · Modifying array elements in place · Using conditional logic while processing arrays · Checking loop bounds and avoiding invalid indices · Debugging array code that does not compile or behaves incorrectly

An array algorithm turns a one-dimensional array into an answer: a total, a count, an extreme value, a search result, or a changed collection of values.

4.6 Using Text Files

Key concepts: Reading text files with Scanner · Using the File(String) constructor · Closing a Scanner after file input · Handling whitespace when mixing nextLine() with other Scanner methods · Splitting strings with String.split · Regular-expression restrictions for split delimiters · Understanding method specifications and preconditions · Using custom Location objects with 2D arrays · Navigating an int[][] grid with GridPath.getNextLoc · Checking adjacent strings with indexOf and returning boolean results

A text file is persistent data: unlike keyboard input, its contents remain available after the program stops. Java reads that stored data through a Scanner whose input source is a File object rather than System.in.

4.7 Wrapper Classes

A Java ArrayList cannot store a primitive such as int; it stores objects, so Java provides wrapper classes, object types that package primitive values for use wherever an object is required.

4.8 ArrayList Methods

Key concepts: Using ArrayList to store and manage objects · Adding objects to an ArrayList with add · Writing methods that return an ArrayList · Iterating through arrays or lists with a for loop · Constructing objects and adding them to a list · Building match pairings from competitors · Handling odd and even numbers of competitors · Preserving the required order of elements · Avoiding incorrect indices or extra elements in a returned list · Calling methods with syntactically correct syntax

An ArrayList is a resizable collection: unlike a fixed-length array, it can grow when new objects arrive and shrink when objects are removed. A tournament program, for example, can read competitor names, construct Competitor objects, store them in an ArrayList, and later create Match objects from those competitors.

4.9 ArrayList Traversals

Key concepts: ArrayList traversals

An ArrayList traversal visits the elements of an ArrayList in sequence so that a program can inspect, display, compare, or process each stored object. The central question is simple: How can a program examine every element without knowing the list’s contents in advance?

4.10 Implementing ArrayList Algorithms

Key concepts: ArrayList · User-made classes · Storing objects · Traversing data · Array algorithms · Word Search Creator Lab · The add() method · buildMatches() method · Match objects · Pairing competitors

An ArrayList algorithm turns a stored collection of objects into useful information: pair competitors, find the highest score, count qualifying entries, or identify a particular object.

4.11 2D Array Creation and Access

Key concepts: Creating a correctly sized 2D array of integers · Assigning a 2D array to the instance variable `puzzle` · Traversing a 2D array with valid row and column bounds · Accessing individual 2D array elements · Generating uniform random integers in the range [1, 9] · Updating each visited 2D array element · Avoiding out-of-bounds errors · Handling neighboring row and column locations

A two-dimensional array is a grid in which every value is located by two indices: a row index and a column index. In Java, puzzle[row][col] means “go to row row, then select column col within that row.”

4.12 2D Array Traversals

A two-dimensional array traversal visits a grid systematically, usually one row at a time, so that every element is examined exactly as intended.

4.13 Implementing 2D Array Algorithms

A two-dimensional array algorithm turns a grid of values into a useful result: a seating chart becomes an occupancy report, a map becomes a terrain analysis, and a matrix of temperatures becomes a search for the hottest region.

4.14 Searching Algorithms

A searching algorithm examines a collection of values to determine whether a target exists and, often, where it occurs. The simplest question is deceptively powerful: how much of the collection must the program inspect before it can safely answer?

4.15 Sorting Algorithms

A sorting algorithm rearranges a collection into a chosen order, such as smallest to largest. The central question is not merely whether the values become ordered, but how the algorithm moves through the collection and what work it repeats.

4.16 Recursion

Recursion is a technique in which a method solves a problem by calling itself on a smaller version of that problem. The method must eventually stop calling itself; otherwise, the calls continue until the program runs out of stack space.

4.17 Recursive Searching and Sorting

Key concepts: Recursive searching · Recursive sorting · Searching algorithms · Sorting algorithms · Recursion · Structural requirements of recursion · Memory and variable behavior during recursive calls · Tracing recursive calls · Recursion compared with iteration · Practice 4 computational thinking

A recursive search or sort solves a large data problem by applying the same algorithm to a smaller portion of the data, then combining the result with the suspended work of the earlier calls.

AP Practice 1

Key concepts: AP Computer Science A course and exam framework (effective Fall 2025) · Computational thinking practices and learning objectives · Program design and implementing a design or specification · Debugging programs · Data abstractions and data types · Determining initial conditions for code · Libraries in programming · Program documentation · Variables and primitive values · Assessing evidence and sources in AP courses

A correct Java program is not merely one that compiles: it must begin with appropriate conditions, use data abstractions correctly, and implement a clearly described design.

AP Practice 2

Key concepts: Java data types, including int, double, Boolean values, and reference types · Casting and the range of variables · Boolean expressions and compound operators such as && and || · Methods and control structures · Writing, tracing, and analyzing Java program code · Debugging code by identifying and correcting errors · Initial conditions required for code to work as intended · Classes, objects, and encapsulation · Using the Java Quick Reference · AP Computer Science A assessment format

A debugging task is not solved by guessing what the programmer intended; it is solved by tracing the actual values, identifying the violated condition, and changing only what prevents the program from meeting its specification.

AP Practice 3

A class-design response earns credit by turning a precise specification into a usable Java class: private data, a constructor that establishes a valid object, and methods whose behavior matches the stated contract.

AP Practice 4

A two-dimensional array is best understood as a grid: one index chooses a row, and another chooses a position within that row. On an AP Computer Science A free-response question, success depends less on writing a clever algorithm than on translating the grid’s meaning into precise traversal, selection, and return…

AP Practice 5

A two-dimensional array stores data in a rectangular grid, but an AP Computer Science A free-response task rewards more than producing the right final number: it rewards correct traversal, valid indexing, appropriate updates, and code that matches the requested behavior.

AP Practice 6

A useful computer program can still cause harm when it collects more data than necessary, hides important conditions, or produces results that people cannot reasonably question.

Source Materials

Study AP Computer Science A on Lykke

This course page is free to open: signed out, you can read its first two sections, and signing in, on any plan, opens the rest. The free Lykke Chrome extension syncs your own Canvas courses, so ChatGPT, Claude and Muse can answer from your classes and deadlines. It only reads Canvas.

Add the free extensionSign in to open every section

Browse more course pages