The inheritance relationship is a form of reuse where we establish one class as a parent or superclass and another class as a child or a subclass. The child class inherits all of the non-private members of its parent class, hence the use of the term inheritance. Now, there are some considerations for what makes a good use of inheritance and what does not, but those are out of scope for now, we're going to focus on the mechanics in Java. But you can use the rule of thumb that the phrase x is a y makes semantic sense to you, that the subclass really is a specialized or extended version of the parent class semantically. For example, suppose we need to include a station wagon as a type of car. Well, does it make sense to say a station wagon is a car? I think so too. Station wagons need all of the same attributes and methods as any other car, so we're going to inherit that. We also need to define, in this particular example, cargo capacity and current cargo load. Rather than copying and pasting, we're simply going to use inheritance to automatically do that for us. Let's look at a diagram for this. Here we have Car, Car has speed, Car has gasoline, Car has engineState, and car has behaviors of setSpeed and getSpeed. StationWagon, in turn, will inherit all of these capabilities, so everything I can say about Car I'll be able to say about StationWagon, but then we're going to want to add some additional attributes. Let's actually do this live. Here is our existing Car class. Now, I am going to move this into a package of its own just so we can keep things a little bit more organized. Refactor, Move, I'm going to create a new package, so it's going to be demos.transport and that's now done. There's Car in demos.transport, look what happened to the CarApp, that's already been updated to know exactly where Car is. Now that I've done that, I'm going to go in here, and I'm going to create a new class, I'm going to call my class StationWagon and I'm going to change my superclass, I don't want to be directly under Object, I want to be under Car; I typed Car to do the filter, here, Car and that's the one I'm looking for, click "Okay". I think I actually do want the constructors from my superclass, so we're going to have the same constructors as our superclass. I don't need a main, I'll just leave that as a default, but we don't have any abstract methods to worry about, and I'm going to click "Finish". Here is StationWagon and we have all the default constructors. In fact, not only did it inherit them from the parent class but it is in fact using this keyword super, which we will cover in detail later to invoke the parent class. You don't see that in the no-argument constructor because that's actually default behavior. I already have now a StationWagon, I'm not going to make any more changes to that for now. Let's go over to the CarApp and let's now change and add another car here. We'll create a new Car, a wagon, we'll just use the constructor, it takes a name, we'll go ahead and set the manufacture date since we try to print that out, and that will be a LocalDate, and we'll now add it to our list. Now, we can go ahead and run the app. There we are, the Wagon Queen Family Truckster, let go correct my spelling, corrected the spelling, there's my enter. We've got it working. Now, what we haven't done is added any of the features yet, so let's quickly go ahead and put them in. We want private int cargoCapacity, we want private int currentCargoLoad. We're going to move these actually. Remember I talked earlier about, we may as well keep the constructors first, so I put these towards the end. Now, let's go ahead and generate our setters and getters. We only want one for the moment, we want set currentCargoLoad, it's the only one I want. Generate Setters and Getters, that's pre-selected and I only currently want the setter according to our little document, so that's all I'm going to bother to do; there is the setter, I could have moved it up. Now, I have that, I can go back to the CarApp, wagon.set, and you'll notice the CargoLoad option isn't here because I defined my reference to be of type Car, that's perfectly acceptable for the fact that all station wagons are cars. But now I want to talk about it as what it actually is with an additional feature, so I'm going to go quickly change my reference to StationWagon. Now, when I look for the available list of options, oh, there's the one that I wanted, I'll just put in a number here, 500. Nothing else for us to do, we can still run the program, there won't be any change because we're not actually using it yet, that will come later. There we've looked at modifying Car, creating a StationWagon subclass, demonstrating that it works, adding these additional features, demonstrating that that works, noticing that the reference has to be StationWagon to be able to talk about StationWagon things. When the reference was a Car, even though the instance was a StationWagon, the reference was acting like a filter; I can't see things that are part of the subclass when I only have a parent class reference type, I had to have the child class reference type to be able to talk about the child classes extensions. That's a quick little look at this.