Unit 3 — Class Creation
Unit 3 is where you learn to design classes and write methods like AP expects:
instance variables, constructors, method headers, return values, scope, and the this keyword.
Study topics 3.1–3.9 first, then take the Unit 3 quiz: 15 MCQ + 1 FRQ.
Topic pages
Go in order (3.1 → 3.9).
How to use the quiz
- Answer MCQs first. Don’t check as you go.
- Click Check Answers to see score + explanations.
- Try the FRQ, then reveal the sample solution.
Unit 3 Quiz — Multiple Choice (15)
Choose the best answer. (One correct option each.)
1) Which best describes abstraction in AP CSA?
2) Which design choice most improves code reuse?
3) Which line is a valid instance variable declaration inside a class?
4) Which is true about constructors?
5) What is returned by this method call?
public int addOne(int x) {
return x + 1;
}
return sends a value back to whoever called the method.6) Which is true about parameters?
7) Which statement about object references is correct?
8) Which is a class (static) method call?
Math.abs is called on the class name (static method).9) What is the scope of a local variable declared inside a method?
10) Which use of this is most common in constructors?
this.x = x; assigns the parameter into the instance variable.11) In a well-designed class, why are instance variables often private?
12) Which method signature correctly returns a String and takes an int parameter?
String, parameter type is int.13) What happens when you assign one object reference variable to another?
14) Which is true about static (class) variables?
15) Which statement about access is correct?
Unit 3 Quiz — FRQ (1)
This FRQ focuses on designing a class with instance variables, a constructor, and methods (Unit 3 skills).
FRQ 1) Counter class
Write a class Counter that represents a counter that starts at an initial value.
The class must include:
- An instance variable that stores the current count.
- A constructor
public Counter(int start)that sets the initial count tostart. - A method
public void increment()that increases the count by 1. - A method
public int getValue()that returns the current count.
Write your solution here:
Sample solution
public class Counter {
private int count;
public Counter(int start) {
count = start;
}
public void increment() {
count++;
}
public int getValue() {
return count;
}
}
Uses a private instance variable, constructor initialization, and simple instance methods.