 Don't let the cute animals fool you. We are actually introducing this idea of abstract classes. Now abstract classes are not that difficult at the same point in time. By now you should have learned about inheritance, being able to make one class and then make subclasses that inherit all the abilities of this parent class. Well that's what the abstract class is. It's actually just kind of looking at some of those parent classes and going well, do we really necessarily need them? Say for example, let's think about the idea that if you look at all these pictures, there are actually all sort of mammals. The monkey, the cat, the sheep, tiger, people, we're all mammals. All mammals have sort of like-minded traits. There's the word we're looking for, like-minded traits. We all have fur or hair for human sake. We're all warm-blooded. We all have sort of ear bones, the inner ear structure. Our mothers will give birth and then nurse them with their own milk. We have a backbone, we have that spine. We all breathe in air, dry air. That's why animals, mammals like dolphins and whales have to surface when they're underwater. They have to breathe in. Well again, this idea right here, this is still a very conceptual thing. For example, can you point to the monkey? I really hope so if you're watching this video. But can you point to a mammal? I know you can point to all of them because they're all mammals, but can you actually show me a picture of a thing, a thing that is the mammal, the mammal. It's a physical thing. Well you can't. It's because mammals are just concepts. What we can do with that is now we can think about that in this idea of creating something known as an abstract class. And it's exactly as it sounds. Mammals are a concept, so they're sort of abstract. I can't physically make a mammal, but I can make a dog, I can make a cat, I can make a panda, a sloth. Those are things that can be physical manifestations of the mammal class. So at least as we start to build on this idea, when we start to look at something like the UML diagrams, one of the things you'll see is all these different animals, they inherit from a mammal class. But notice a few different little subtle nuances. My mammal name, for example, is in what is known as italics. Now that's just to indicate that this is an abstract class. But then take a look at these two guys right here. These are known as abstract methods. So why do we design out an abstract class? Well one of the things that you might notice if we see we've got a make sound and sleep. Alright, well make sound. All of these animals are going to make a sound, but they're all going to make a different sound. Dogs go wolf, cats go meow, tigers go roar, humans talk, soups go bah. I don't really know what a sloth does, but he probably makes some hideous sound. But we all make something. All these mammals make a sound. So instead of putting it all in each one of them, what we can do is we can actually sort of treat it like a blueprint. We can say, oh hey, I know every mammal has a sound. And so what I'm going to do is I'm going to just make sort of a placeholder. Just like we did when we were designing out methods. I'm going to make a placeholder called make sound. I know it's going to return a string. It takes no parameters. And whenever I create an object that extends mammal, then and only then would I actually have it work or have it need to implement it. Now why do we continue to do this? Again, like I said, mammals are abstract concepts. But through polymorphism, what this allows us to do is now say, well, a mammal I can make. I can make bingo. And just like we learned in polymorphism, I can create a mammal that is equal to something that inherits from it. So again, dog inherits from mammal. So I can go mammal equals new dog, or mammal bingo equals new dog. Mammal po equals new panda, mammal atom equals new human. The one thing I can't do is I cannot say mammal equals new mammal. Again, because mammal is a concept, so I can't just make a mammal. They don't exist. So what we have to do is we have to explicitly pick out one of its subclasses, one of its child classes to implement from. Now why do we do this? Well, what happens is if we kind of take a look at a few different things, you see that we've got a bunch of different classes here that have a bunch of different things. Some of them have, well, a lot of them actually, if you notice, are implementing their diet. Some mammals are omnivores, like the monkey and the dog. Some mammals, like sheep, are herbivores. And then some mammals, like the tiger, are carnivores. So even though that we're all the same, we do have some subtle differences. Like, again, the tiger and the sheep are polar opposites on the kind of dietary chart. Well, what this allows me to do is because I, again, have this diet right here, I have diets specified as a every mammal has a diet kind of thing. What I can do is now if I'm creating mammals, if I'm creating mammals, I have access to these methods. And I'm already stating that these methods and these variables exist. So in this case, what I can do is I can actually start to implement these things. Again, this will allow me to kind of build that out. All mammals are warm-blooded. All mammals have fur. But we all have a different diet, for example. So again, what can I do with this? Well, if I then make a method, I don't know what kind of mammals I'm going to be dealing with. But I know I'm going to be dealing with two mammals, such as can one mammal eat the other mammal? Can M1 eat M2? Again, I don't know what the mammals are, but I know that they're going to be at least of the mammal abstract class. Well, because each mammal is going to have some diet, hopefully it's been implemented. But because they're going to have some diet, what that allows for me to do is now grab, say, M1's diet and M2's diet and say, does it equal carnivore? And does M2, does it equal herbivore? If that is the case, we'll just go ahead and say that my carnivore can, in fact, eat my herbivore. If it's an omnivore, no, they fight back, they can bite too. But if my carnivore is a carnivore, if my mammal, one, is a carnivore, and my mammal, two, is a herbivore, mammal one can eat it. And we see that. If I then go into any method, my main method, and I create a mammal tiger and a mammal sheep. Sheep, again, a mammal tiger was a carnivore. And sheep was an herbivore. Well, can x, x being a carnivore, and can x eat y? Well, if we follow that kind of rule that my method says, x becomes M1, y becomes M2. If M1's diet equals carnivore, true. And M2's diet equals herbivore, also true. Since both of these are, in fact, true, this gets equated out as true. Return true. Can a tiger eat a sheep? True.