The big idea: A non-static (instance) variable belongs to each object — every object has its own copy.
A static (class) variable belongs to the class itself — there is exactly one copy, however many objects exist.
Step to 'Static': one shared count, and three objects each with their own title.
Interactive diagram
Explore the labelled diagram, charts and maps for this topic in full study mode.
Free preview
This is the free notes preview
You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:
- FlashcardsLock in vocabulary and key terms with spaced repetition.
- Practice questionsAnswer exam-style questions and get instant AI marking.
- Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
- Personalised study planA daily plan built around your exam date and weak areas.
Instance (non-static)
- One copy per object
- Reached through the object: b1.title
- Holds what makes this object different from the others
- Created when the object is, destroyed with it
- The default choice
Static (class)
- One copy for the whole class
- Reached through the class: Book.count
- Holds what is true of all objects, or counts them
- Exists even when no objects have been created
- Use only when the value genuinely belongs to the class
A counter must be static: "How many Books have been created?" cannot be an instance variable — each object would hold its own count of 1.
The answer belongs to the class, because it is about the class, not about any one book.
Study smarter, not longer
Most students waste 40% of study time on topics they already know. Our AI tracks your progress and optimizes every minute.
An instance method uses the object
A static method does not
Static cannot reach instance data
When to use each
Shared means shared: Changing a static variable changes it for every object at once, including ones created later.
That is the point when it is a counter — and a source of surprising bugs when it was meant to be per-object.
How this is tested — you must justify each choice from whether the value belongs to one object or to all. It comes up two ways:
Paper 2 — working with code
- Distinguish static from non-static, 3-5 marks
- Choose which a stated variable should be
- Say why a static method cannot use instance data
Paper 2 — the algorithmic-thinking question
- Reason about shared values with no code shown
- Explain the effect of changing a class variable
The classic trap: Making something static because it feels like a shared setting. Ask: would every object have the same value, always? If not, it must be an instance variable.
A BankAccount class holds an account balance and the bank's current interest rate, and must count how many accounts exist. Decide static or non-static for each, with reasons.
Model answer plan
See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.