This HL programming topic covers object-oriented programming (OOP): how objects and classes work, and the four pillars β encapsulation, inheritance, polymorphism and abstraction.
Work through each screen, answer the questions as you go (some are wordy, some are calculations) and collect β stars. Press Start when you are ready.
A class is a blueprint; an object is an instance of a class. A class defines:
Creating an object from a class is instantiation; a special method called the constructor sets up a new objectβs starting state.
Encapsulation bundles data and the methods that act on it inside one class, and restricts direct access to the data. Attributes are usually made private, reachable only through public getter and setter methods. This protects the data and hides the internal representation.
Inheritance lets a subclass acquire the attributes and methods of a superclass, then add or change behaviour. It models an is-a relationship (a Dog is an Animal) and promotes code reuse. A subclass can override an inherited method to specialise it.
Polymorphism means one interface, many forms. A method such as draw() or speak() can be overridden so it behaves differently for each subclass, and the correct version is chosen at run time (dynamic dispatch). Method overloading defines several methods with the same name but different parameters.
Abstraction hides complex detail and exposes only the essential features. An abstract class or interface declares what methods must exist without giving all the implementation, letting programmers work with simple, general concepts.
Tap an idea, then the OOP pillar it best fits.
UML class diagrams show each class as a box with three parts: the name, the attributes, and the methods. Lines show relationships such as inheritance (an arrow to the superclass) and association. UML helps design and communicate an OOP solution before coding.
Tap a pillar on the left, then its definition.
Instantiation creates an object from a class. The constructor is a special method that runs automatically at creation to set the objectβs starting attribute values. Each object then has its own copy of the instance attributes.
An instance attribute or method belongs to each object separately. A static (class) member belongs to the class as a whole and is shared by every object β useful for counters or constants.
OOP encourages modular, reusable code. Encapsulation protects data, inheritance avoids repetition, and objects map naturally onto real-world entities, which makes large programs easier to maintain and extend. A trade-off is added design complexity for small programs.
Class vs object: blueprint vs instance; constructor sets up state
Encapsulation: private data, public getters and setters
Inheritance: subclass is-a superclass; code reuse and overriding
Polymorphism: one interface, many forms; overriding and overloading
Abstraction: hide detail, expose essentials (abstract classes, interfaces)
UML: class boxes with name, attributes and methods
You have covered the OOP HL programming topic. Press Finish to see your score.
You have worked through Object-oriented programming. π
Your stars: 0 / 0
Next: test yourself in the Evaluate stage Confidence Quiz, then lock it in with Verify.