课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
What is inheritance?
- [Instructor] Another key object-oriented principle is Inheritance. Inheritance allows us to create class hierarchies where classes inherit properties and behaviors from other classes. With Inheritance, we have two main players, the subclass and the superclass. We call the class that inherits the properties the subclass or child class. The class that's being inherited from is called the superclass or the parent class. In Inheritance, the child class inherits properties from the parent class, or the subclass inherits properties from the superclass. For example, let's say we have an employee class. The class has name, ID, and salary attributes. Now what if we wanted to represent a salesperson in code? A salesperson would also have a name, ID, and salary, but they might also have a commission percentage or other attributes and behaviors. While we could create a fresh new class for the salesperson with name, ID, and salary attributes, we could also use Inheritance to help reduce code in…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
(已锁定)
What is inheritance?2 分钟 41 秒
-
(已锁定)
Leveraging different types of inheritance2 分钟 49 秒
-
(已锁定)
Using inheritance to reduce code duplication4 分钟 51 秒
-
(已锁定)
Discovering inheritance in foundational Java classes3 分钟 18 秒
-
(已锁定)
Challenge: Reduce redundant code with inheritance1 分钟 51 秒
-
(已锁定)
Solution: Reduce redundant code with inheritance4 分钟 37 秒
-
(已锁定)
-
-
-