Results

Cambridge November 2026 results: AS & A Level on 7 January 2027, IGCSE and O Level on 14 January 2027.

Source: Cambridge International
STUDY GUIDE

AP CSA Object References and Aliasing Practice

Separate the variable that stores a reference from the object it identifies. Two variables can refer to the same object even when their names differ.

Book your free 30-minute demo

Updated November 2026.

By LearnAllStudents Editorial Team. Source check dates are listed below.

Follow the worked example

Suppose Box has an integer count field. Box a = new Box(3); Box b = a; After b.setCount(9), a.getCount() returns 9.

The assignment copies the reference, so one object changed. It did not create a second Box.

Now let b = new Box(2). The new assignment changes what b refers to. a still identifies the earlier Box with count 9.

Place the listing inside a Java class. Try the worked example’s inputs from its main method.

static final class Box {
  private int count;

  Box(int count) {
    this.count = count;
  }

  void setCount(int count) {
    this.count = count;
  }

  int getCount() {
    return count;
  }
}

static int[] traceBoxCounts() {
  Box a = new Box(3);
  Box b = a;
  b.setCount(9);
  int afterMutation = a.getCount();

  b = new Box(2);
  return new int[] { afterMutation, a.getCount(), b.getCount() };
}

Draw objects separately from variables

Draw a box for each object created with new and an arrow from each variable that refers to it. Assigning one reference to another copies an arrow. A setter changes the box. Reassigning a variable moves only its arrow.

Try it yourself

After c = a, call c.setCount(5). Then set c = null. What does a.getCount() return?

Check your reasoning

5. The method changed the first Box before c stopped referring to it.

Use the idea in a different situation

What change to the original code would give b independent state at construction?

Check the second task

Use a new Box with a starting value, rather than assigning a’s reference directly.

For parents

Ask, “When b is set to a new Box, what happens to the first Box?”

They should keep the first box and its value, then move only b’s arrow to the new one.

Use paper arrows for the variables. Move arrows for assignments and change values inside boxes for setter calls.

How a tutor would approach this

Write down the expected output or state before running the Java code. Compare it with the actual output, trace where they first differ and test the fix against another input that arrives at the same kind of boundary.

Frequently asked questions

What mistake should I look for first?

Reassigning a reference changes the variable. Calling a method that mutates the object changes every view of that same object.

How can I use this with a longer practice set?

Read the current course framework and official sample questions before deciding how to practise this technique in an exam-length task.

Are these official past-paper questions?

The worked example and practice tasks here are original. The sources section links to the official material for your course.

How can I tell if I can use the method on a new question?

Try the second task with the worked example covered. Explain which step needs to change and why before checking the answer.

Official sources

Related pages

Try a free 30-minute demo

Work through a question with a tutor. No payment needed.

Request a free 30-minute demo
YOUR NEXT STEP

A little clarity starts with 30 minutes.

Share your goals, explore a question and discuss a learning plan. Request your free 30-minute demo class — no payment needed. Tutor and time are confirmed separately.

Book your free 30-minute demo
Book free demoWhatsApp us