AP CSA Unit 3.6: Object References and Pass by Reference Practice

Unit 3, Section 3.6
Day 6 Practice • January 12, 2026
🎯 Focus: Object References

Practice Question

Consider the following class and method:
public class Point {
    public int x;
    public int y;
    
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

public static void move(Point p) {
    p.x = p.x + 5;
    p.y = p.y + 5;
}

// Client code:
Point pt = new Point(2, 3);
move(pt);
System.out.println(pt.x + " " + pt.y);
What is printed as a result of executing the client code?

What This Tests: Section 3.6 covers passing object references to methods. When you pass an object to a method, you pass a reference to the same object—changes to the object persist after the method returns.

Key Concept: Reference vs Value

// PRIMITIVES: pass by value (copy)
int x = 5;
change(x);  // x is still 5 after

// OBJECTS: pass by reference
Point pt = new Point(2, 3);
move(pt);   // pt IS changed after!

Step-by-Step Trace

Step Action pt.x pt.y
1 new Point(2, 3) 2 3
2 move(pt) - p refers to same object 2 3
3 p.x = p.x + 5 7 3
4 p.y = p.y + 5 7 8
5 Print pt.x + " " + pt.y 7 8

Common Mistakes

Mistake: Answer A (2 3)

This assumes objects work like primitives—that changes in the method don't affect the original. But p and pt reference the SAME object, so changes persist!

Visual Model

Think of References as Addresses

pt holds the address of a Point object

move(pt) copies that address to p

Both pt and p point to the SAME object in memory

Changing p.x changes the object that pt also references

Difficulty: Medium • Time: 3 minutes • AP Skill: 3.B - Object references

Ready to Level Up Your AP CSA Skills?

Get personalized help or access our complete question bank

Premium Question Bank - Coming Soon Schedule 1-on-1 Tutoring
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.