aimnova.
DashboardMy LearningPaper MasteryStudy 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
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

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

NotesComputer Science HLTopic 7.1Classes and objects
Back to Computer Science HL Topics
7.1.46 min read

Classes and objects (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

  • Defining, then creating
  • What the constructor is for
  • Methods, and using the objects
  • Exam-style question
The big idea: Defining a class writes the template. Instantiating creates an actual object from it.

The class is written once; objects are created as often as you need them.
The big idea: Defining a class writes the template. Instantiating creates an actual object from it.

The class is written once; objects are created as often as you need them.

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

It runs automatically

  • Called when the object is created, never by you directly
  • Python names it __init__; Java names it after the class
  • Whatever you pass at creation arrives as its parameters

It sets the starting state

  • Gives every attribute a value before anything can use it
  • So no object ever exists in an unfinished state
  • onLoan starts False — a new book is not on loan

It can refuse

  • Checks can be made before the object exists
  • An empty title can be rejected at creation
  • Far better than allowing a broken object and hoping
What self means: self is the object the method was called on.

self.title is this book's title; another object's method call has a different self. It is what lets one method definition serve every object.
What self means: this is the object the method was called on.

this.title is this book's title; another object's method call has a different this. It is what lets one method definition serve every object.
Not every attribute is a parameter: title and author come from outside, because they differ per book.

onLoan is set inside to a sensible default — a new book is never on loan, so asking the caller would be pointless and error-prone.

See how examiners mark answers

Access past paper questions with model answers. Learn exactly what earns marks and what doesn't.

Try Exam Vault FreeYour first topic is free to keep • No credit card required
1

Every method takes self

2

Methods return, rather than print

3

Objects behave like any value

1

Every method has a this

2

Methods return, rather than print

3

Objects behave like any value

Java, briefly: Java names the constructor after the class — public Book(String title) — and writes this.title where Python writes self.title.

The structure and the reasoning are the same; only the spelling differs.

How this is tested — you must write a constructor that sets every attribute, and methods that return. It comes up two ways:

Paper 2 — working with code

  • Construct a class with a constructor and methods, 4-6 marks
  • Create objects and call their methods
  • Explain what the constructor does

Paper 2 — the algorithmic-thinking question

  • Explain the role of a constructor with no code shown
  • Say why an attribute has a default rather than a parameter
The classic trap: Forgetting to set an attribute in the constructor. An object then exists with a missing value, and the failure appears much later — somewhere that has nothing to do with the cause.
IB-style questionConstruct[6 marks]

Write a Student class holding a name and a list of marks, with a method to add a mark and one to return the average. Create two students and use both methods.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic
IB-style questionConstruct[6 marks]

Write a Student class holding a name and a list of marks, with a method to add a mark and one to return the average. Create two students and use both methods.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Classes and objects. Write your answer and get instant AI feedback — just like a real IB examiner.

why two objects of the same class can hold different values. [2 marks]

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

7.1.1Fundamentals of OOP
7.1.2Designing classes
7.1.3Static vs non-static
7.1.5Encapsulation
View all Computer Science HL topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science HL

Previous
7.1.3Static vs non-static
Next
Encapsulation7.1.5

28 exam-style questions ready for you

Students who practice on Aimnova improve their scores by 15% on average. Get instant feedback that shows exactly how to improve your answers.

Practice Now — FreeView All Computer Science HL Topics