Overriding methods. This is a component of inheritance where we're going to have methods and subclasses that have the same name, and exactly at the same method header as ones in their superclass or parent class, but they'll behave differently. So they that allows you the special, remember we said, there was generalization like you could put all the things that were generalizable up in the superclass, and specialization where we could say that there are some classes that behave a little bit specially, and so that's exactly what overriding methods is for. Now we're also going to jump back into overloading methods. So I don't like so much in CSAwesome is, it doesn't state very, very clear, overloading has absolutely nothing to do with inheritance. We're only bringing it up right now because it has a name that's similar to overriding, but overloading was actually covered back in Section 5 when we're talking about creating methods. And that's where you can create methods that have the same name but different parameters and they might do different. So you have to overload a constructors like all the time, right? Zero argument constructor or three argument constructor, etc. So little bit of a teacher tip there. 9.3 is just, this is of course how you expect things to behave. And then the pet sounds programming challenge is fun and easy. All right, overriding. So I highlighted the key thing. Overriding an inherited from your superclass method is providing a public method in the subclass with the exact same method signature. And I think I probably told you before it's like signature is not a terribly important for students to know. And I'd still argue with that. But probably at this point, we've gotten comfortable enough with classes that maybe it's a good time to go ahead and add that vocabulary in, at this point. Signature just means, the name, the parameter list, and the return type, all. Those three things together, that's the method signature. We sometimes called the method header. And so overriding, it must be equal. They must be the exact same things in the superclass and the subclass. So for example, we've got an example, they called public class greeter. At the top, it has a method called public string greet. And then there's a mean greater, which is the subclass of its extends greeter, and their greeting would be specialized in different. They're mean, they're not going to say, hi. They're going to say go away. But the key thing here, you'll notice, same signature or method header, name, return type, parameter list. No parameters, name is greet, return type string. And it's really important, they put a nice big blue box, must be exactly the same. Yes. This next teeny little bit, you can just skip. It's about, use the Java doc commands. This is not covered on AP CSA rarely, though we cover it, so you can skip it. Now again, overloading, we're going to take and jump into. But it should say very prominently, completely unrelated to inheritance, and by the way, yeah, we also talked about earlier. But what is it? Overloading a method is when several methods in the same class have the same name but different parameter types, order, or number, okay? And it can't just be the return type, it has to be about the parameter types, order, or number. So an example of that was, within the same greet class or greeter class, we could have two greet methods. One, it doesn't take any parameter, and one that takes a string of like, who you're greeting, okay? So we've seen this before. And a nice blue box to say exactly the same thing. So then there's two questions that are great to just get students to be like, are you sure you were listening there, okay? If we have a student class that extends person, what would correctly override the get food method? Well, here's the get food method in person. So it needs to have the same signature or method header. So you don't have to know what it is, you're just going to pick the same signature method header. And then overloading, okay, is in the same class, which you'd find the equations in person, will correctly overload get food in person, anything with a different signature or method header. And it's actually going to have same name, but going to be different parameters or order of parameters. All right, 9.3.2. It's not that these paragraphs are bad, or wrong, or incorrect, they're just sort of like saying, by the way, just because you're a subclass of a superclass, you can't just go and directly access those instance variables. Those are private up in say, person. You're going to have to use the getters and setters. So I would just say, subclasses must use the getters and setters of the parent superclass. Just because they are subclass, they don't get to access those private things. Remember private means, only in that same dot Java file and subclasses are in different dot Java files. Which I admit, isn't terribly obvious when you're using CSAwesome because they have the special way that you don't actually have to have two files open to use it, but they would be in separate files. Let's talk about the programming challenge, it's pet sounds. The basic design here is we're going to have a superclass called pet and a subclass called dog. And actually then, there's going to be a cat one at the end, okay? But a dog is a pet, a cat is a pet. Are all pets dog? No. Okay, so that's the way that the ordering goes, pet will be the superclass because all dogs are pets. Okay, you can probably argue about that one, but you get what I'm talking about. Okay, what do they have and kids do? Basically, two, three parts here. Make the subclass, dog, that inherits from pet, write a constructor and then override the speak method. This is what you're going to have. They're going to have to say, extends pet. I think they actually put the class, dog, there from to start, maybe not, and then write the constructor. Now a dog doesn't actually, in this particular instance have any new instance variables that pets don't have, but if you look at the pet constructor, it needs two things. It needs a name and a type of an animal. So there you are. And then the speak method is says, woof. By the way, this is the speak method in the pet class. By default, the superclass says, grr. That's not terribly obvious, but okay, whatever. And then finally, basically write a similar cat class that is extending the pet class, inherits from pet, has a constructor and overrides. So it's just basically the same thing, except, now our constructor is going to give them the name of the pet, and the cat, and then speak will be, meow. The one thing I'll say about that, and this is kind of appropriate because we're in the inheritance chapter. That programming example only shows overriding, and so we wouldn't talk about overloading and we're not actually showing the difference between them. But just so you know that.