From the course: Java 8 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Understanding inheritance and polymorphism

Understanding inheritance and polymorphism - Java Tutorial

From the course: Java 8 Essential Training

Start my 1-month free trial

Understanding inheritance and polymorphism

- I previously described encapsulation but there are two other concepts that you need to master to be a great object-oriented programmer, Inheritance and Polymorphism. Inheritance means that there's a relationship between classes in your application that lets you inherit or extend functionality from one class to another. Not all object-oriented languages are the same, for example, C++ supports multiple inheritance, but in Java, there's only single inheritance. Each class can extend or inherit functionality from only one other class. This actually makes it a lot easier to manage your code. If you run into a bug, that bug can either be in the class that you're working on, or in its direct superclass, or in its superclass, and so on. But the issue has to be somewhere in that very linear path. But Java does allow you to implement multiple interfaces in a single class. We'll get to interfaces later. There are a number of different ways to describe an inheritance relationship, but these are…

Contents