Join Peggy Fisher for an in-depth discussion in this video Understanding inheritance, part of Learning Java.
- The next topic that I'd like to talk about is inheritance. Inheritance is when one class is created from another. Inheritance is also a benefit of object-oriented programming. The new class "inherits" all the instance data and methods from the base class, thus reducing data redundancy. There are numerous real life examples of this concept. For example, we might identify a bug class, which describes a wide range of creatures. So ladybugs, grasshoppers, ants are all bugs.
They all have some common characteristics, but each one has additional features specific to them. For example, a grasshopper can hop, a ladybug can fly. When this type of relationship exists, we can say that a ladybug is a bug, a grasshopper is a bug, an ant is a bug. This is the generic form of inheritance. A poodle is a dog, a car is a vehicle, a circle is a shape. The key here is the two words "is a." This means that the specialized class has all the characteristics of the general class, but it also has additional characteristics that make it unique.
The benefit of inheritance is that we can define one base class, such as the "bug class," and then extend that to other classes that inherit these characteristics plus more. It reduces the amount of coding we need to do. When we use inheritance, we use key words, "extends" and "implements." To sum up, inheritance is when one object acquires the properties from another object.
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.