AP Exam Study Cheat Sheet/Notes
Study Guide
Method
- 8 FRQ/1 Full Practice Exam/week
- No help allowed (no docs, no reference sheet, no compiler)
- Unlimited time to solve
- Self-score after doing FRQ/exam
- External research/compiler for testing allowed after self-scoring
Testing Resources (8 FRQ or 1 Practice Exam/Week)
CB Assigned FRQs & MCs CB Past FRQs
CB Topics Cheat Sheet
Key Sites
Topic Summary
Primitive Types
- Java has 8 primitive types:
int
,double
,boolean
,char
,byte
,short
,long
,float
. - Variables store simple values, e.g.,
int x = 5;
ordouble price = 3.99;
. int
for whole numbers,double
for decimals,boolean
fortrue/false
.
Objects
- Classes define object types, and objects are instances of those classes.
- Use
new
keyword to create objects:String s = new String("hello");
. - Call methods with dot notation:
s.length()
orMath.abs(-4)
.
Boolean Expressions and if Statements
- Booleans:
true
,false
; operators:&&
,||
,!
. - Conditional statements:
if (x > 5) { // do something } else { // do something else }
- Use
equals()
to compare strings:str1.equals(str2)
.
Iteration
for
,while
, anddo-while
loops repeat blocks of code.- Common use: traversing arrays or ArrayLists.
for (int i = 0; i < arr.length; i++) { // loop body }
Writing Classes
- A class includes fields, constructors, and methods.
public class Dog { private String name; public Dog(String n) { name = n; } public String getName() { return name; } }
Array
- Fixed-size containers:
int[] nums = new int[5];
. - Use
nums.length
and index access:nums[0] = 1;
.
ArrayList
- Resizable array:
ArrayList<String> list = new ArrayList<>(); list.add("hello"); list.get(0);
- Requires
import java.util.ArrayList;
.
2D Array
- Arrays of arrays:
int[][] grid = new int[3][4]; grid[0][1] = 5;
- Access with
grid[row][col]
; use nested loops to iterate.
Inheritance
- A subclass inherits from a superclass using
extends
.public class Dog extends Animal { // subclass code }
- Use
super()
to call superclass constructors or methods.
Recursion
- A method that calls itself.
- Must include a base case and a recursive case.
public int factorial(int n) { if (n == 0) return 1; return n * factorial(n - 1); }
MCQ
FRQ
2014: Problem 1 Work Revised
(Coded in REPL, includes test case)
public class Main {
public static void main(String[] args) {
recombine("john", "mort");
String[] words = {"apple", "pear", "this", "cat", "doge", "fish", "blat", "pent"};
mixedWords(words);
}
public static String recombine(String word1, String word2) {
String finalString = "";
String[] words = {word1, word2};
for(int i = 0; i < words.length; i++) {
if(i == 1) {
for(int j = words[i].length()/2; j < words[i].length(); j++) {
finalString += words[i].charAt(j);
}
}
else {
for(int j = 0; j < words[i].length()/2; j++) {
finalString = finalString + words[i].charAt(j);
}
}
}
System.out.println(finalString);
return finalString;
}
public static String[] mixedWords(String[] words) {
String tempW = "";
for(int i = 0; i < words.length; i+=2) {
tempW = recombine(words[i], words[i+1]);
words[i+1] = recombine(words[i+1], words[i]);
words[i] = tempW;
}
return words;
}
}
Output
jort
apar
peple
that
cis
dosh
fige
blnt
peat