aımnova
DashboardMy LearningCrash CoursesStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Crash Courses
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Teachers
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aımnova

IB study, practice and feedback built around the real exam.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.c1e448f

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 7.1Static vs non-static
Back to Computer Science HL Topics
7.1.34 min read

Static vs non-static (Computer Science HL)

IB Computer Science · Unit 7

Exam preparation

Practice the questions examiners actually ask

Our question bank mirrors real IB exam papers. Practice under timed conditions and track your progress across topics.

Start Practicing

Contents

  1. 1Belonging to the object, or to the class
  2. 2The distinction in code
  3. 3Static methods, and scope
  4. 4Exam-style question
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.

Claim your free topic

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.
Start Studying Free Full access to Aimnova Pro · cancel anytime
class Book:
    count = 0                     # STATIC — one copy, for the class

    def __init__(self, title):
        self.title = title        # INSTANCE — one per object
        Book.count = Book.count + 1

b1 = Book("Dune")
b2 = Book("Emma")

print(b1.title, b2.title)         # Dune Emma — separate values
print(Book.count)                 # 2 — one shared counter
class Book {
    static int count = 0;             // STATIC — one copy, for the class
    String title;                     // INSTANCE — one per object

    Book(String title) {
        this.title = title;
        Book.count = Book.count + 1;
    }
}

Book b1 = new Book("Dune");
Book b2 = new Book("Emma");

System.out.println(b1.title + " " + b2.title);   // Dune Emma — separate values
System.out.println(Book.count);                  // 2 — one shared counter

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.

Try Smart Study FreeYour first topic is free to keep • No credit card required
1

An instance method uses the object

borrow() needs to know which book, so it uses the object's own data — in Python it receives self.

It cannot be called without an object, because there would be nothing for self to refer to.

2

A static method does not

It belongs to the class but uses no object's data — so it can be called as Book.howMany() with no object at all.

That is the test: does it need an individual object's values?

3

Static cannot reach instance data

There is no object to reach it on. A static method asking for an instance field has no idea which object is meant, so it is an error.

Instance methods can use both, since they have an object and the class is always available.

4

When to use each

Instance for anything about one particular thing. Static for counters, shared settings, and helpers that belong to the class but need no object.

In doubt, choose instance: sharing one value between every object is a decision, not a default.

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.
IB-style questionDistinguish[5 marks]

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 answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Static vs non-static. Write your answer and get instant AI feedback — just like a real IB examiner.

whether a method returning a student's age should be static, and your answer. [2 marks]

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

7.1.1Fundamentals of OOP7.1.2Designing classes7.1.4Classes and objects7.1.5Encapsulation
View all Computer Science HL topics
Improve your exam techniqueCommand terms, paper structure, and mark-scheme tips for Computer Science HL
Previous7.1.2Designing classesNextClasses and objects7.1.4

21 practice questions on Static vs non-static

Students who practiced this topic on Aimnova scored 82% on average. Try free practice questions and get instant AI feedback.

Try 3 Free QuestionsView All Computer Science HL Topics