From the course: Java Object-Oriented Programming
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
What is inheritance? - Java Tutorial
From the course: Java Object-Oriented Programming
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
What is inheritance?2m 41s
-
(Locked)
Leveraging different types of inheritance2m 49s
-
(Locked)
Using inheritance to reduce code duplication4m 51s
-
(Locked)
Discovering inheritance in foundational Java classes3m 18s
-
(Locked)
Challenge: Reduce redundant code with inheritance1m 51s
-
(Locked)
Solution: Reduce redundant code with inheritance4m 37s
-
(Locked)
-
-
-