
You understand variables, loops and functions. Then your teacher introduces classes, constructors and objects that call their own methods. Suddenly, a simple program seems to have several places where its data can change. How do you know which object owns a value, what a method will print, or whether inheritance is even required?
Those are the questions worth practising for IB Computer Science 2027 OOP. The revised syllabus, first assessed in May 2027, places object-oriented programming in Theme B, the computational thinking and problem-solving theme. In a September 2026 r/IBO discussion, a new HL student described struggling with a fast programming pace alongside classmates with more experience. The takeaway is not that you must arrive already fluent: build your ability to read, trace and construct small programs systematically.
What OOP Is Actually on the 2027 Syllabus?
The official guide divides B3 into B3.1, single-class fundamentals for SL and HL, and B3.2, multiple-class fundamentals for HL only. The recommended teaching allocation is seven hours for SL and 23 hours for HL.
| SL and HL: B3.1 | HL extension: B3.2 |
|---|---|
| Classes, objects and the advantages and disadvantages of OOP | Inheritance and access to parent-class members |
| Designing classes, methods, attributes and UML class diagrams | Dynamic and static polymorphism, including overriding |
| Constructors and creating objects | Abstraction and abstract classes |
| Static versus instance variables and methods | Composition versus aggregation |
| Encapsulation, information hiding and access control | Singleton, factory and observer design patterns |
There is a subtle distinction: SL students should understand inheritance and polymorphism conceptually as part of evaluating OOP fundamentals, but constructing multi-class implementations belongs to the HL-only B3.2 section. Avoid studying from old materials that describe OOP only as an optional unit from the course last assessed in 2026.
For 2027, Paper 2 assesses Theme B, including programming. It lasts 1 hour 15 minutes at SL and two hours at HL, contributing 35% and 40% respectively. Students answer the Java or Python version corresponding to the language studied. The options are equivalent; you do not need to learn both languages for the exam. The two-language examples below are for comparison.
Classes, Objects, Attributes and Methods
A class defines a type of object. Its attributes describe state, and its methods define behaviour. An object is a particular instance created from the class. For example, two tickets can be created from one Ticket class but retain different seat counts.
A constructor sets the initial state when an object is created. In Python, __init__ performs instance initialisation; in Java, the constructor uses the class name. Both examples model the same simple reservation system.
Python example:
class Ticket:
issued = 0
def __init__(self, seats):
self.__seats = seats
Ticket.issued += 1
def reserve(self, amount):
if 0 < amount <= self.__seats:
self.__seats -= amount
return True
return False
def remaining(self):
return self.__seats
a = Ticket(5)
b = Ticket(4)
a.reserve(2)
print(a.remaining(), b.remaining(), Ticket.issued)
Java equivalent:
class Ticket {
private int seats;
public static int issued = 0;
public Ticket(int seats) {
this.seats = seats;
issued++;
}
public boolean reserve(int amount) {
if (amount > 0 && amount <= seats) {
seats -= amount;
return true;
}
return false;
}
public int remaining() { return seats; }
}
class Main {
public static void main(String[] args) {
Ticket a = new Ticket(5);
Ticket b = new Ticket(4);
a.reserve(2);
System.out.println(a.remaining() + " "
+ b.remaining() + " " + Ticket.issued);
}
}
Both programs output 3 4 2. Object a now has three available seats, b still has four, and the shared class variable issued counts two constructed objects.
Encapsulation and Static Versus Instance State
Encapsulation combines state and behaviour within a class and controls how that state can be accessed. A caller uses reserve() rather than changing the seat count directly. The method rejects negative reservations and attempts to reserve more seats than are available.
Java's private modifier restricts direct access to seats outside its class. Python's double-underscore __seats triggers name mangling, which discourages accidental access but is not a security boundary. Do not claim that Python has Java-style enforced privacy.
An instance variable such as seats belongs to each ticket. A class or static variable such as issued is shared across the class. This is why changing a does not change b, while creating either ticket increments the shared total. Static methods belong to the class rather than an individual object's state; instance methods typically operate on a specific object.
For UML, sketch a rectangle headed Ticket, with attributes - seats: int and + issued: int {static}, followed by operations such as + reserve(amount: int): boolean and + remaining(): int. The - indicates private visibility and + public visibility in UML. The Java example uses private for the seat count and public for the constructor and methods, matching these UML visibility indicators.
HL: Inheritance and Polymorphism in Action
Inheritance allows a child class to extend a parent class. Polymorphism allows the same method call to behave differently depending on the object. Method overriding supplies a new implementation in a subclass.
Python tracing example:
class Entry:
def label(self):
return "General"
class VideoEntry(Entry):
def label(self):
return "Video"
items = [Entry(), VideoEntry()]
for item in items:
print(item.label())
Java equivalent:
class Entry {
String label() { return "General"; }
}
class VideoEntry extends Entry {
@Override
String label() { return "Video"; }
}
class Main {
public static void main(String[] args) {
Entry[] items = {new Entry(), new VideoEntry()};
for (Entry item : items) {
System.out.println(item.label());
}
}
}
The output in each language is General, then Video. In Java, the variable type Entry does not prevent the runtime from selecting VideoEntry.label() for the subclass object. That is dynamic dispatch. Java method overloading, where methods share a name but have different parameter lists, is a common example of static polymorphism; Python does not use Java-style signature-based method overloading.
HL students should also know abstraction, which exposes essential behaviour while hiding implementation detail. An abstract class can define methods that subclasses must supply. Composition represents strong ownership of component objects; aggregation represents a looser relationship in which components can exist independently. The HL guide also names singleton, factory and observer patterns. Learn the purpose and trade-offs of each rather than assuming every question requires a full design-pattern implementation.
Original Paper 2-Style Code-Reading Questions
These questions are independent practice exercises, not official IB past-paper questions.
Question 1: Trace state (SL and HL). Using the Ticket program, what prints after b.reserve(5) and then b.reserve(1) if you output b.remaining()? Answer: 3. The first call fails because only four seats are available. The second succeeds and reduces four to three. A failed call must not change the object's state.
Question 2: Identify a design error (SL and HL). A programmer replaces self.__seats with Ticket.seats in a Python reservation method, intending each ticket to track its own seats. What is wrong? Answer: This confuses per-object state with a shared class attribute; the method should update the current object's instance attribute. The precise runtime outcome also depends on whether a class attribute named seats exists.
Question 3: Trace polymorphism (HL). Add items.append(VideoEntry()) before the Python loop. What prints? Answer: General, Video, Video. The inherited type supplies a common interface; the actual object determines which overridden method runs.
Question 4: Evaluate a design (HL). Should a School always inherit from Student to reuse a name field? Answer: No. A school has students; it is not a kind of student. A collection of Student objects held by School expresses an aggregation relationship more accurately than inheritance.
Common Errors and an Exam Revision Routine
Watch for confusing a class with an instance, forgetting to initialise attributes, sharing data accidentally, calling an instance method without an object, and assuming every subclass method is inherited unchanged. In Python, check indentation and self. In Java, check declared types, constructor calls, access rules and method signatures. During tracing, maintain a small table with one row per object and update attributes only when a statement executes.
Revise in a sequence: draw a simple UML class; write its constructor and two methods; construct two objects; trace successful and unsuccessful calls; then explain encapsulation and class-versus-instance state. If you study HL, add overriding, multiple-class relationships and concise explanations of abstraction and patterns. Practise in your chosen exam language, and review the current IB specimen questions with your teacher. The IB's 2027 FAQ says Paper 2 has Java and Python options and that particular questions may explicitly prohibit certain built-in functions.
Final Checklist: Can You Explain What the Code Does?
Before Paper 2, check that you can identify a class and an object, distinguish attributes from methods, initialise objects, explain access control, identify shared versus instance data, and trace state changes without guessing. For HL, add inheritance, overriding, abstract classes, composition, aggregation and design patterns.
The strongest preparation for IB Computer Science 2027 OOP is not memorising longer definitions. It is explaining why a design fits a problem, predicting each object's state and writing small correct programs.
Official references: IB Computer Science curriculum updates; IB Computer Science 2027 subject brief; Computer Science guide, first assessment 2027 (archived copy of the IB guide); IB Computer Science 2027 FAQ (archived copy).
Student discussion: r/IBO, IB DP1 Computer Science: Is This Fair?, September 2026.
Table of contents
Share
Related reading
- IB Computer Science 2027: Paper 1 vs Paper 2 ExplainedUnderstand IB Computer Science Paper 1 vs Paper 2 for 2027, including SL and HL timings, marks, Theme A, Theme B, case studies and revision strategies.
- IB Computer Science 2027 Paper 2: Python or Java?Prepare for IB Computer Science Paper 2 2027 with Python and Java examples, algorithm tracing, debugging, OOP guidance and a practical exam revision plan.
- IB Computer Science Case Study 2027: AI Image CreationPrepare for the IB Computer Science case study 2027 with clear explanations of diffusion models, GANs, AI image ethics and practical Paper 1 exam advice.
- IB Computer Science IA 2027: Criteria, Format and ExamplesUnderstand the IB Computer Science IA 2027 rubric, 2,000-word report, video and code appendix. Explore a worked project example and practical evidence tips.
- Can IB Math AI HL Get You Into Computer Science in 2027?Can IB Math AI HL get you into Computer Science? Compare 2027 university entry rules at Oxford, UCL, Cambridge and more to choose your subjects confidently.
- IB Computer Science: What You Really Study and BuildIs IB Computer Science right for you? Explore the 2027 syllabus, SL and HL papers, coding expectations and IA requirements before choosing your DP subjects.
- IB Exam Timetable 2027: Dates and Paper Schedule GuideCheck the IB exam timetable 2027, verify May dates and November updates, find your exam zone and build a personal paper schedule. Read the full guide now.
- MYP Integrated Sciences vs Separate Science Exams: GuideCompare MYP Integrated Sciences with separate Biology, Chemistry and Physics exams. Learn what differs, which notes fit and how to revise effectively.
