Inheritance
Multiple-class OOP adds relationships and flexible behaviour through inheritance, polymorphism, abstraction, composition and patterns.
What you need to be able to do
- Explain + applyAnd apply the concept of inheritance in OOP to promote code reusability
Rapid Recall Deck
Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.
- What is inheritance in OOP?: A mechanism where a child/subclass derives state or behaviour from a parent/superclass and can extend or specialize it.
- What relationship does inheritance usually model?: An 'is-a' hierarchical relationship, such as ElectricCar is a Car.
- How does inheritance promote code reuse?: Common functionality can be defined once in a parent class and inherited by multiple child classes.
- How can a child class extend a parent class?: It can add new members and may override inherited behaviour where the language permits.
- How do access modifiers affect inheritance?: Public/protected members are generally accessible according to the language's rules; private parent members are not directly accessible from the child class.
- When is inheritance a poor design choice?: When the relationship is not genuinely hierarchical or when reuse would create tight coupling between classes that should remain independent.
Core knowledge and application
And apply the concept of inheritance in OOP to promote code reusability
Multiple-class OOP adds relationships and flexible behaviour through inheritance, polymorphism, abstraction, composition and patterns.
Explain it without notes
Explain + apply: And apply the concept of inheritance in OOP to promote code reusability in the context of a school platform with multiple interacting object types.
- How inheritance enables a hierarchical relationship between parent and child classes
- Extending existing classes, utilizing inheritance to reuse and extend functionalities
- The impact of inheritance on access to parent class members with different access modifiers (private, public, protected, default)
Programming checkpoint
class User:
def __init__(self, name):
self.name = name
class Student(User):
def __init__(self, name, grade):
super().__init__(name)
self.grade = gradeclass User {
protected String name;
User(String name) { this.name = name; }
}
class Student extends User {
private int grade;
Student(String name, int grade) {
super(name);
this.grade = grade;
}
}Modify it
Change one condition, input or operation so the program solves a slightly different problem. Predict the effect before editing.
Transfer to a new scenario
- How inheritance enables a hierarchical relationship between parent and child classes
- Extending existing classes, utilizing inheritance to reuse and extend functionalities
Paper 2 practice
- Explain + apply: And apply the concept of inheritance in OOP to promote code reusability in the context of a school platform with multiple interacting object types.
Finish the learning cycle
IA — main task
Continue Criterion D development. Keep code readable, record meaningful implementation decisions, and maintain testing/evidence notes as you work.
Syllabus — short
Complete one targeted Paper 2/Paper 1 retrieval task from today’s lesson.