CAIE 9618 · Paper 2 · Topic 2.4.1
Programming
Concepts
OOP · Scope · Parameters (Value vs Reference) · Recursion
CSZone
Cambridge International AS & A Level Computer Science 9618
Object-Oriented Programming
Classes, Objects & the 4 Pillars
OOP models programs around objects — instances of classes. A class is a blueprint; an object is a created instance with its own attribute values.
ENCAPSULATION
Bundling data (attributes) and methods together in a class. Private attributes accessed only through public methods (getter/setter). Hides internal implementation.
INHERITANCE
A subclass inherits attributes and methods from a parent class. Avoids code duplication. e.g. Dog INHERITS Animal.
POLYMORPHISM
The same method name behaves differently for different classes. e.g. makeSound() on Dog returns "Woof", on Cat returns "Meow". Method overriding.
ABSTRACTION
Hiding complex implementation details. Users interact with a simplified interface (public methods) without knowing how they work internally.