AP Computer Science A — Free Practice Questions, Study Guides & Mock Exams
Learn Java programming fundamentals, object-oriented programming, data structures, and algorithms
Topics covered
- Variables and Data Types
- Operators and Expressions
- Conditional Statements
- Loops
- Arrays
- ArrayList
- 2D Arrays
- Methods
- Objects and Classes
- Inheritance
- Polymorphism
- Recursion
- Sorting and Searching
- Algorithm Analysis
Free AP Computer Science A study guides
- Represent Patterns and Algorithms — Input, steps, output — and the four workhorse patterns behind every program.
- Compilation and Execution — The two gates between typing a program and running it, and why a compiler that checks for only some errors makes a clean compile a much weaker claim than it sounds. AP CS A learning objective 1.1.B.
- Programming Error Types — Compile-time, runtime, logic: three error types that ambush three different stages.
- Data Type Categories — Primitive or reference — does the variable hold the value, or directions to it? Four step-by-step memory diagrams show the difference the moment you reassign. AP CS A learning objective 1.2.A.
- Primitive Variable Declarations — Type, name, value: the declaration promise, the four working types, and snapshot copies.
- Output Statements — print vs println and the traveling cursor, plus left-to-right concatenation rules.
- String Literals and Escape Sequences — Two written characters, one stored: \n, \", and length that counts escapes as one.
- Arithmetic Expressions — Precedence, integer division, and mod — the three facts behind every arithmetic trace.
- Assignment Statements — Right first, then store: the command meaning of =, self-referencing updates, and swaps.
- Input — The Scanner pipeline: input is a queue, each call consumes the next piece, in order.
- Primitive Casting — Widening is free, narrowing costs the fraction — and cast placement decides the answer.
- Integer Range and Overflow — The int odometer wraps: past 2.1 billion, values flip sign with no warning.
- Round-Off Error — Doubles approximate: why 0.1 + 0.2 isn't 0.3, and the tolerance idiom that replaces ==.
- Compound Assignment Operators — += and friends: shorthand with a memory — the operator's rules survive the compression.
- APIs and Libraries — Packages, libraries, and API specifications — and how to identify a class's attributes and behaviors from documentation alone, without ever seeing its source. AP CS A learning objective 1.7.A.
- Documentation with Comments — The three Java comment forms, and the two promises a method makes — precondition and postcondition — that decide who is at fault when it misbehaves. AP CS A learning objective 1.8.A.
- Method Identity and Signatures — Name plus parameter list is identity; return type and parameter names are cosmetic.
- Method Calls, Return Values, Arguments, and Overloading — Values in, value out: positional binding, substitution thinking, and overload selection.
- Calling Class Methods — Static methods are reached through the class — no object, no construction, just the name path.
- Math Class — Exactly five tools — abs, pow, sqrt, random — and the range-scaling pattern.
- Objects: Instances of Classes — What separates a class from an object, what a class hierarchy actually claims, and exactly where the exclusion statement stops the course.
- Reference Type Variables — Primitives store values, objects store addresses — and copies behave differently.
- Constructor Signatures — No return type, ever: the checklist that separates constructors from name-wearing methods.
- Reference Variables for Objects — Many names, one object: aliasing, counting news, and null as a name for nothing.
- Object Instantiation — new does three things in one expression — and every new is a distinct birth.
- Calling Instance Methods — object.method(args): the receiver supplies context, and chains run left to right.
- String Objects, Immutability, and Concatenation — Strings never change — operations give birth. What looks like change is rebirth.
- String Methods — Five methods on one index ruler: length, substring, indexOf, equals, compareTo.
- Selection and Repetition — Sequencing, selection and repetition — the three blocks every algorithm is built from, and why moving a decision inside or outside a loop gives you a different routine. AP CS A learning objective 2.1.A.
- Relational Boolean Expressions — Six comparison operators on the number line, the = vs == trap, and why integer division poisons comparisons.
- One-Way and Two-Way Selection — if filters, if-else forks: exactly one branch runs, the else is the precise negation, and braces always.
- Nested and Multiway Selection — The else-if ladder: first true test wins and stops. Strict-to-loose ordering, or the lower rungs die.
- Compound Boolean Expressions — && demands both, || accepts either — and both short-circuit. The guard pattern puts the safe test left.
- Equivalent Boolean Expressions — De Morgan's rules: negate, swap, distribute — and comparisons flip their boundary when negated.
- Object Reference Comparisons — == asks which box, equals asks what's inside. Aliasing, exact-case matching, and the null guard first.
- Iteration Need and Loop Errors — Every loop is initialize, test, update — and fails in one of three ways: infinite, zero passes, off-by-one.
- while Loop Processes — Prime, test, work, advance: sentinel runs and goal-driven processes where the pass count is unknown.
- for Loop Processes — Three semicolon slots: init once, test before every pass, update after every body. Traces read themselves.
- Numeric Selection and Iteration Algorithms — The digit machine (% reads, / deletes), divisor finding, and running extremes — selection inside iteration.
- String Selection and Iteration Algorithms — substring windows sweep by index: count, search, and build new strings — immutability forces walk-and-build.
- Nested Iteration Processes — Loops inside loops multiply. The full grid visits every pair; j = i + 1 keeps each unordered pair once.
- Informal Run-Time Analysis — Growth class, not clock time: one loop is linear, loop-in-loop quadratic, halving logarithmic. Doubling tells.
- Class Design with Abstraction — Deciding what a class knows and what it can do, on paper. Data abstraction, attributes, procedural abstraction and method decomposition. AP CS A learning objective 3.1.A.
- Impact of Program Design — System reliability, the social and economic impact of shipping software, and who owns the code you reused. AP CS A learning objective 3.2.A.
- Access, Visibility, and Encapsulation — The visibility matrix, encapsulation's payoff, accessors/mutators as checkpoints, and a free-response style task.
- Constructor State Initialization — Constructor anatomy, defaults, overloading, initialization order, and the return-type trap.
- Writing Methods with Primitive Values — Seven recipes: direct boolean returns, double casts, every-path returns, and the copy-in/copy-out rule.
- Passing and Returning Object References — References as remote controls: mutation vs reassignment, returning fields, and identity vs equality.
- Class Methods — What a static method can reach, what it cannot, and the one way to hand it an object anyway — plus why main is static and what that forces on you. AP CS A learning objective 3.7.A.
- Class Variables and Constants — static = one shared slot, static final constants, and the access boundary between static and instance.
- Scope and Shadowing — Where a variable is visible, why parameters are local variables, and the shadowing rule behind the constructor that compiles, runs, and quietly does nothing. AP CS A learning objective 3.8.A.
- The this Keyword — Shadowing, the this.x = x idiom, the reversed accident, and scope-ring lookup order.
- Privacy Risks in Data Collection — Why collecting and storing are two different risks, why minimisation is the one safeguard that survives a compromise, and why the class you write for question 3 is already a record about people.
- Data Quality and Bias — Algorithmic bias, the collection method that decides who gets counted, and why incomplete or inaccurate data makes correct code produce wrong answers. AP CS A learning objective 4.1.B.
- Appropriate Data Sets — Why a data set can be complete, accurate and fairly collected and still be the wrong one for the question being asked of it — proxy measures, original purpose, granularity, and the three-step check.
- Using Data Sets — Draw the table first. Why every data-set algorithm visits values one at a time, what each one carries forward, and how a chart is used to plan the algorithm. AP CS A learning objective 4.2.A.
- Array Creation and Access — Why the length can never change, why nothing in an array is ever empty, and why the last index is always one less than the count.
- Array Traversals — The hidden assignment inside every enhanced for loop — why it can never write into an array, and why it can still change every object an array points at.
- Array Algorithms — Sum, max, count, and search on arrays — the four workhorse loops plus the shift patterns.
- File I/O
- Wrapper Classes — Why an Integer object can never be edited once it exists, the exact four situations in which the compiler boxes or unboxes for you, and why parsing text is a different operation entirely.
- ArrayList Methods — All six exam methods on one table, the add/remove index shift traced step by step, and the four traps that cost the most points.
- ArrayList Traversals — Indexed vs enhanced walks, what each can do, and the skip bug when removal meets the enhanced cursor.
- ArrayList Algorithms — The accumulator family on ArrayLists: sum, max, count, transform with set, and backward pruning.
- 2D Array Creation and Access — Row-first addressing, the two lengths, rectangularity, and reading cells by formula.
- 2D Array Traversals — Nested loops: the outer index picks row-major or column-major, and the output fingerprints which.
- 2D Array Algorithms — Grid versions of the workhorses, row/column slices as single loops, and in-place transforms.
- Linear Search Algorithms — Walk until found or finished: the sentinel -1, best and worst cases, and cost growth with size.
- Iterative Sorting Algorithms — Selection and insertion traced pass by pass: invariants, swap counts, and when each wins.
- Recursive Method Calls — Base case plus recursive case, traced as stack frames: descent, then values climbing back up.
- Recursive String and Collection Traversal — Head plus rest over strings and lists: substring(1), index-passing, and the recursion tree as trace.
- Binary Search — The halving window: low, high, mid, the <= bound, and why sortedness is the entry fee.
- Merge Sort — One array traced the whole way down and the whole way back, because the objective asks for the result of each iteration — including the merge order students most often get wrong.
Units
- Unit 1
- Unit 2
- Unit 3
- Unit 4