Python Inheritance Basics
Multiple Choice Medium
Question
If class B inherits from class A, and both define `speak()`, which runs when you call `B().speak()`?
Hint
The child class overrides the parent.
Explanation
When a child class (B) defines a method with the same name as the parent (A), the child's version overrides the parent's. So B().speak() calls B.speak(). To call the parent's version, use super().speak().
Related Resources
Related Lessons
- Inheritance
Method overriding.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.