FortyFive › Revision notes › IB Computer Science › IB Computer Science: B3 · Object-oriented programming
IB Computer Science: B3 · Object-oriented programming
Classes, objects, inheritance, encapsulation. 2 subtopics, 8 key terms.
In this topic: B3.1 · B3.2
B3.1Object-oriented programming fundamentals
Key terms
- Class
- A blueprint defining attributes and methods.
- Object
- An instance of a class.
- Constructor
- A special method that initializes a new object (__init__ in Python).
- Encapsulation
- Bundling data with methods and restricting direct access (private attributes, getters and setters).
Encapsulation protects data from invalid changes and hides implementation details.
The full notes, worked example and check questions for this subtopic are in the app.
Exam tip: In code questions, name the constructor, attributes and methods explicitly, using the class's own names.
B3.2Inheritance, polymorphism and design HL
Key terms
- Inheritance
- A subclass acquires the attributes and methods of a superclass.
- Polymorphism
- The same method call behaves differently depending on the object's class (overriding).
- Abstraction
- Exposing only essential features, e.g. abstract classes or interfaces.
- Composition / aggregation
- An object contains other objects: strong ownership / weak association.
Inheritance models an "is-a" relationship (a Circle is a Shape); composition models "has-a" (a Car has an Engine).
The full notes, worked example and check questions for this subtopic are in the app.
Exam tip: Use the phrases 'is-a' (inheritance) and 'has-a' (composition) to justify your design choices.
← B2 · Programming · B4 · Abstract data types (HL) →
← All IB Computer Science topics