IB Computer Science: Multi-Class OOP — Inheritance, Polymorphism, Abstraction and Design Patterns (tutor lesson plan; a child class reaches 2 of 4 parent members)
- 2026-11-28
Students can write one class, but ask whether a child class may read the parent balance and the answer stops. Multi-class OOP tests three things: the modifier decides what a child can see, overriding and overloading decide when binding happens, and composition or aggregation decides whether a part can outlive its owner.
01 Prerequisites (3-minute check)
If any of these fails, fix it before the lesson starts.
| Skill | Quick check | Pass mark |
|---|---|---|
| Classes and objects | which of the loan class and Chan’s loan has a real due date? | the object |
| Method signatures | may one method name carry two different parameter lists? | yes, that is overloading |
| Percentages | what percentage of 35.0 is 20.0? | 57.1% |
02 Lesson flow (60 minutes)
| Time | Stage | Tutor does | Student does |
|---|---|---|---|
| 0-8 min | Opening check | can a child read a parent private member? | write an answer first |
| 8-22 min | Inheritance and four modifiers | 4 members, child reaches 2 | fill the access table |
| 22-36 min | Polymorphism | 10-day fines 35.0 against 15.0 | trace three outputs |
| 36-46 min | Abstraction | 2 abstract methods, 6 implementations | write the abstract class |
| 46-54 min | Composition, aggregation, patterns | 3 order lines, 2 students | sort four cases |
| 54-60 min | Exit check | three questions marked on the spot | work alone |
03 Teaching script (read it out)
Scene 1: Inheritance and the four modifiers — what a child can see
Build a table with four rows, private, default, protected and public, and four columns: same class, subclass in the same package, subclass in another package, and any other class. Private is the class alone; default allows the package; protected reaches subclasses even from another package; public reaches everyone. Ask for the sentence protected is the channel left open for subclasses and private is not, because that sentence separates the two for good.
Then count the savings: 40 lines in the parent, 8 in the student loan and 8 in the staff loan gives 56 lines with inheritance; written separately each class needs 48 lines for 144 in total, so inheritance saves 88 lines, 61.1%. Make the class say what is saved: the 40 shared lines are written once, not that the code is shorter by a few words.
Close with one test: the child must be a kind of the parent. A student loan is a loan and the sentence works, but a borrower is not a book, so that case needs composition rather than inheritance.
Student task: write out the four parent members with their modifiers and, for each, whether the child can use it directly, then check all four answers against the table.
Scene 2: Polymorphism — overriding is dynamic, overloading is static
Trace the fines to show dynamic binding: three loan types override the fine method at 0.5, 1.0 and 2.0 per day, so 10 days give 5.0, 10.0 and 20.0, a total of 35.0. The loop runs three times with no test on the type and still prints three different answers, and that is dynamic binding. Had the parent rate of 0.5 been used, all three would be 15.0, short by 20.0, which is 57.1%, and that arithmetic is the answer to why overriding earns its keep.
Use three versions for overloading: fine(days), fine(days, rate) and fine(days, rate, cap), 3 versions of one name that the compiler tells apart by the argument count. Ask for the benefit, one concept under one name instead of fineWithRate, and the limit, the parameter lists must differ and changing only the return type is not overloading.
Finish with the trade-off: dynamic binding is flexible but needs a run-time lookup, static binding is fixed early and faster. On a question asking which form is resolved at compile time, answer overloading and give that reason.
Student task: write the three overriding methods and one loop that calls them, put the three outputs and the total of 35.0 in a trace table, then add one overloading example.
Scene 3: Abstraction, composition and patterns — keep the change in one place
Then split composition from aggregation with one question: can the part exist without the owner? An order and its lines are composition, because deleting the order destroys its 3 lines and a line without an order means nothing. A tutor and the students are aggregation, because deleting the tutor leaves the 2 students alive with their own life cycle. Ask for the two verbs owns and uses: composition owns, aggregation uses.
Give each pattern a purpose and a number. Singleton: a configuration object must exist once, so the constructor is private and a static method hands out the instance, and 100 calls return 1 object; without the guard the program builds 100 objects of 2 KB each and wastes 198 KB, 99.0%. Factory: 3 loan types are built from a code by one factory, so 12 call sites name no class and a fourth type changes one file. Observer: one subject with 5 observers sends 100 notifications across 20 events without knowing any observer class, only the interface. Ask for the common thread: each pattern takes the part that varies and puts it behind one place.
Student task: classify the four cases (order, tutor, configuration, notification) as composition, aggregation, singleton or observer, and state what happens to the 3 order lines and the 2 students when the owner is deleted.
04 Question types and worked steps
| Type | Example | Steps | Answer |
|---|---|---|---|
| Decide whether inheritance fits | 4 parent members, two subclasses | three steps: say the is-a sentence, list the shared members, leave the rest to the subclass | child reaches 2 (50%); both private members stay closed |
| Trace polymorphic output | three loan types at 10 days | three steps: read each object type, find that type override, multiply and add | 5.0, 10.0, 20.0, total 35.0 |
| Overriding or overloading | one fine method with three versions | two questions: is the parameter list the same? same means overriding (dynamic), different means overloading (static) | 3 overloads; overriding needs inheritance |
| Composition or aggregation | an order with 3 lines, a tutor with 2 students | one question: can the part live alone? no means composition, yes means aggregation | lines die with the order; students survive |
| Choose a pattern | one instance, build by type, or notify many | three questions: unique means singleton, build by code means factory, one-to-many means observer | singleton gives 1 object from 100 calls |
05 Independent practice (3 questions)
| Question | Answer | What to watch |
|---|---|---|
| a parent class has 4 members (2 private, 1 protected, 1 public). (a) how many can a subclass reach directly? (b) how are the others read? | (a) 2, that is 50%; (b) through a public parent method such as the period getter | private is not protected; a subclass cannot read it |
| a loan runs 10 days and the three rates give fines of 5.0, 10.0 and 20.0. (a) what is the total? (b) how much is lost at the 0.5 parent rate? | (a) 35.0; (b) 15.0, short by 20.0, which is 57.1% | dynamic binding follows the object type, not the declared type |
| a configuration singleton serves 100 calls, and 5 observers watch 20 events. (a) how many objects exist? (b) how many notifications are sent? | (a) 1; (b) 100 | a singleton is one, not zero; notifications are observers times events |
06 Common mistakes and what to say
| Mistake | Student writes | Say this |
|---|---|---|
| Treating a parent private member as inheritable | the subclass assigns the parent balance directly | private means even the subclass cannot touch it. You may use 2 of the 4 members directly and the rest only through a public method, or encapsulation means nothing. |
| Calling overloading dynamic | the answer says the version is chosen from the object at run time | overloading is fixed at compile time from the argument list; only overriding is dynamic. Overriding looks at the object, overloading looks at the arguments. |
| Using inheritance where composition belongs | a student loan extends a student | a student loan is not a kind of student, it is a kind of loan. When the is-a sentence fails use composition: the loan holds a student id instead of inheriting the student. |
| Writing aggregation as composition | deleting a tutor deletes the 2 students | students have their own life cycle and a tutor leaving does not remove them. Order lines are composition, 3 of them vanish with the order; tutor and student is aggregation and the 2 stay. |
07 Homework (paper, section and question numbers)
- IB Computer Science chapter index — the three questions on this page are the homework
- OOP basics: one class, UML and encapsulation — prerequisite: classes, constructors and private against public
- Data structures: arrays, lists, stacks and queues — prerequisite: objects and data apart; composition puts objects inside objects
08 Exit check (last 5 minutes)
| Question | Answer | Decision |
|---|---|---|
| Modifiers | a parent has 4 members, how many does a child reach? | four means private was read as protected |
| Binding | which form is fixed at compile time, overriding or overloading? | overriding is the wrong way round |
| Parts | after the tutor is deleted do the 2 students remain? | gone means aggregation was called composition |
09 Tutor FAQ
Must B3.2 be written in all three languages?
No. Paper 2 uses the one language the school chose, Java or Python. What is assessed is the concept and the trace: the modifier effect, the overriding and overloading split, and the composition or aggregation judgement.
How many design patterns must be memorised?
the guide names three: singleton, factory and observer. For each, state the recurring problem and one example: one instance (100 calls, 1 object), building by code (3 types), and one-to-many notification (100 sends).
How are protected and default marked in UML?
UML uses four symbols: # protected, ~ default or package visible, – private and + public. This parent has two -, one # and one +, so the child sees the # and the +.
Find a tutor — freeTutor Registration →
A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.



