Inheritance & polymorphism
HSC Software Engineering · Unit 3: Object-oriented programming
Inheritance & polymorphism notes
Fact-checked by a second, independent AI review.
A concise guide to inheritance and polymorphism in NSW HSC Software Engineering, covering core ideas, terms, and common exam questions.
- Inheritance (is-a relationship)
- Subclass extends a superclass to reuse fields and methods and to specialise behaviour.
- Subclass / Superclass
- Subclass inherits from superclass; superclass provides common features while subclass adds or overrides features.
- Method overriding
- Subclass provides its own implementation of an inherited method to tailor behaviour.
- Polymorphism and dynamic binding
- A superclass reference can point to a subclass object; the correct overridden method is chosen at run time (dynamic dispatch).
- Upcasting / Downcasting
- Upcasting is implicit and safe; downcasting requires type checks and can fail at run time.
- Abstract classes and interfaces
- Abstract classes and interfaces define a contract; they cannot be instantiated and enable polymorphic design.
Remember it: IS-A, OVER-RIDE to ENABLE DYNAMIC DISPATCH—UPCAST for flexibility, DOWNCAST with checks.
Exam tip: Markers want clear definitions, correct terminology, examples of overriding and dynamic binding, and short code or diagram-based explanations. Expect questions like explain inheritance vs. composition, describe polymorphism with a code snippet, or compare upcasting/downcasting.
Syllabus checklist
- Inheritance & polymorphism: core ideas
- Terms and typical exam questions for "Object-oriented programming" in NSW HSC Software Engineering
Practice questions
1. Which keyword enables a class to reuse another class's methods?
Answer checked
Show answer
Answer: extends. In many OOP languages, extends is used to derive from a base class, enabling inheritance of its methods and fields.
2. Polymorphism allows a single method name to behave differently based on the object.
Answer checked
Show answer
Answer: True. True. Polymorphism lets a method act differently depending on the actual object's class at runtime.
3. In OOP, a ____ is a class that inherits from another.
Answer checked
Show answer
Answer: subclass. A subclass inherits from a superclass, acquiring its behavior and possibly extending it.
4. If you have a Dog reference assigned to an Animal variable, which speak() is called?
Answer checked
Show answer
Answer: Dog. Dynamic binding calls the Dog's overridden speak() method at runtime.
5. What OOP concept describes a subclass providing its own implementation of a method from the base class?
Answer checked
Show answer
Answer: method overriding. Method overriding allows a subclass to replace the base class method with its own version.

Practise inheritance & polymorphism as a game
Hearts, combos, streaks and an AI tutor that explains every answer. Start free.