Bạn đang xem thử công khai
Đăng nhập để lưu tiến độ, làm bài tập, thảo luận và nhận phản hồi.
After this unit you will: be able to tell apart the three most commonly confused concepts of OOP.
| Concept | Meaning | Example in this lesson |
|---|---|---|
| Inheritance | A child class reuses everything from its parent class and can add to it or override it (an "is-a" relationship) | class Dog(Animal) |
| Encapsulation | Protecting internal data from being modified arbitrarily | self.__balance + deposit() |
| Polymorphism | The same method name, different behavior depending on the object | speak() of Dog, Cat, Cow |
Use super() to extend a parent class's method rather than replace it entirely.