In simple terms
A friendly intro before the formal notes — no formulas yet.
Programming with Blueprints
Object-Oriented Programming lets us model real-world things as 'objects' in our code. We first design a 'class', which acts as a blueprint, and then we create individual 'objects' based on that blueprint.
Imagine you're a property developer. You don't just start building a house; you first get an architect to draw up a detailed blueprint. This blueprint defines all the properties of a house: number of bedrooms, size of the kitchen, type of roof. The blueprint itself isn't a house, but it's the master plan. Using this single blueprint, you can then build many individual, unique houses. In OOP, the 'class' is the blueprint, and each 'house' you build is an 'object'.
- 1
First, identify a 'thing' you want to represent in your programme, like a 'Car'.
- 2
Next, design a 'class' as a blueprint. Define its properties (attributes like 'colour', 'maxSpeed') and its behaviours (methods like 'accelerate()', 'brake()').
- 3
Then, create specific instances, or 'objects', from the class. For example, a red Ferrari object and a blue Ford object, each with its own state.
- 4
Finally, use encapsulation to protect the object's internal state. You interact with the car using its public methods (steering wheel, pedals), not by directly manipulating the engine parts.
Explore the concept
Use the live diagram and synced steps — play it or tap a step card to walk through.
Full topic notes
Formal explanation with the rigour you need for the exam.
Classes: The Blueprint
A class is the fundamental building block in OOP. It's a template that defines the properties and behaviours of a certain type of object. The properties are stored in attributes (variables), and the behaviours are defined by methods (functions). For example, we could define a Dog class. Its attributes might be name, breed, and age. Its methods could be bark(), wagTail(), and fetch().
Objects: The Real Thing
If a class is the blueprint, an object is the actual house built from it. An object is a specific instance of a class. Using our Dog class, we can create multiple dog objects, each with its own unique state. For example, we could have one object dog1 with , , and . Another object, dog2, could have , , and . Both are Dog objects, but they are distinct entities in the computer's memory.
Encapsulation: The Protective Bubble
Encapsulation is the principle of bundling an object's data (attributes) and the methods that operate on that data together within the class. A vital part of this is data hiding, where we make the attributes private. This means they cannot be accessed or modified directly from outside the class. Instead, we provide public methods, often called 'getters' and 'setters', to act as a controlled interface. This prevents accidental or malicious corruption of an object's state and allows us to add validation logic.
Security: Protects an object's internal state from unintended external modification.
Modularity: The internal implementation of a class can be changed without affecting the code that uses it, as long as the public interface remains the same.
Maintainability: Code is easier to understand and debug because an object's state can only be changed through its well-defined methods.
In Paper 2, when asked to design a class, always explicitly state whether your attributes and methods are public or private. The default assumption should be that attributes are private to demonstrate your understanding of encapsulation. Use getters and setters to provide controlled access.
Worked examples
See the formulas applied — reveal one step at a time, like the exam.
A GameCharacter class is required for a new video game. It needs to store a character's name (String) and healthPoints (Integer). In IB pseudocode, define this class including a constructor to initialise its attributes. Then, show how to instantiate an object named playerOne for a character named "Arion" with 100 health points.
- 1
Here is the solution, with marks allocated as they might be in an exam.
A BankAccount class needs to manage a customer's balance. The balance attribute (a float) must be private. It should be initialised to 0.0 via a constructor. A public method deposit(amount) should add to the balance, and a public method withdraw(amount) should subtract from it, but only if sufficient funds are available. A public method getBalance() should return the current balance. Write the pseudocode for this class to demonstrate encapsulation.
- 1
This solution demonstrates correct encapsulation by protecting the balance attribute.
How it all connects
The big idea sits in the middle — tap a linked idea to explore the link.
Tap a linked idea to see how it connects back to the main topic — that connection is what examiners reward.
Glossary
Try to recall each definition before you reveal it.
Quick check
Answer in your head first — then tap to check. No pressure.
Revision flashcards
Flip the card. Test yourself before the exam.
What is a class?
A blueprint or template for creating objects. It defines a set of attributes (data) and methods (behaviours) that the created objects will have.
Key takeaways
Review these before you close the topic — retrieval beats re-reading.
- ✓
Security: Protects an object's internal state from unintended external modification.
- ✓
Modularity: The internal implementation of a class can be changed without affecting the code that uses it, as long as the public interface remains the same.
- ✓
Maintainability: Code is easier to understand and debug because an object's state can only be changed through its well-defined methods.
Practice — then mark it
The whole point: a real Cambridge question, marked mark-by-mark.
Test Your Knowledge on OOP Fundamentals
Test Your Knowledge on OOP Fundamentals
Extra simulations & links
PhET, GeoGebra and other curated tools — open in a new tab.
Frequently asked
Checkpoint
One marked question is worth ten re-reads — close the loop before you move on.
Reading it isn’t knowing it — prove it.
Before you move on: do Test Your Knowledge on OOP Fundamentals on paper, snap a photo, and get examiner-style feedback on exactly where you win and lose marks.