A Rookie's Guide to Java Part 5 - Classes | Harry Wainwright | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

A Rookie's Guide to Java Part 5 - Classes

teacher avatar Harry Wainwright, BSc Software Engineer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

9 Lessons (52m)
    • 1. Class Introduction: Classes

    • 2. All About Classes

    • 3. Classes - Classes and Methods

    • 4. Classes - Public by Default

    • 5. Classes - Getters and Setters

    • 6. Classes - Constructors

    • 7. Classes - Organizing Classes

    • 8. Classes - Inheritance

    • 9. Classes - Abstraction

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

The fifth class in A Rookie's Guide to Java. We learn about classes in Java, really putting the "object" in "object orientated programming"!

A Rookie's Guide to Java, previously released on Udemy currently holds a 5-star rating and boasts hundreds of happy students. Now I'm bringing it to Skillshare! A Rookie's Guide to Java assumes no prior programming knowledge. We start at the very basics and work our way up to some fairly advanced topics, including Java Swing. This course comes with written material to recap what you've learned at predetermined points. This truly is one of the best ways to learn.

I often see courses claiming that you can "Learn To Make Video Games (No Programming Needed!)" But unfortunately if you want to make anything more advanced than flappy bird you'll need a programming language under your belt. Learning programming is fundamental to any career in the software industry, games or otherwise, and Java is a great starting point.

Meet Your Teacher

Teacher Profile Image

Harry Wainwright

BSc Software Engineer


I have years of programming experience and have spent time working on projects ranging from video games to dynamic websites, and responsive databases. With a particular interest in object orientated programming, I intend to share all here on Skillshare.

Professional, concise, informative tutorials on a variety of object orientated programming languages for all levels of experience.

See full profile

Class Ratings

Expectations Met?
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Class Introduction: Classes: Okay, then classes. So we Finally we finally built up the classes. I'm going to read the section description now. It's kind of trying to give the impression of how important these are. We learned all about class is the most important subject and object orientated programming , and that it's a simple sentence. But it hopefully does leave you with a bit of an idea of how important these are. I covered for these over the course of seven or eight lectures. Um, and I tried to take it slowly as possible. So we we've got the introduction. We got classic methods public by default, was talking about the variables you have public, private, protected. I got gas and says constructors, organizing your classes, inheritance and obstruction. Eso if he found functions difficult, you're probably gonna find classes difficult unlike functions or methods. I've covered this over the course of seven lectures so far, but I may add to that, um, classes, all object orientated programming classes allow you to make an object the object orientated programming. That's where the name comes from. So when I say they are the most important part of this course, I mean it again we take it slowly so I wouldn't be too too worried about it. Ah, but it is important that you it's important to learn classes before you can call yourself at program, should I say 2. All About Classes: Okay, then. Welcome back. Today we're going to be talking about classes. In the last few lectures, we've been talking about methods, and today will be moving on to classes or what we can do with classes. You see, when we talk about programming in Java, we're talking about object oriented programming. Andi, classes are everything to do with that. You can't object orientated programming. You can't do that without classes. We've been using classes, Surfer. Maybe we'll see here. You need one to renew program. This is just something that was created when we created the program is created automatically, but say we're gonna make our own. So first, I'm gonna get rid of all this current from last time, so I don't really need it at night. Maybe I'll come back to it. Anything I wouldn't leave is our main. It's obviously need a main. So to start creating a new class, I'm gonna come out of public class eating hello world here. So let the first bracket and you'll see where ends and then we'll be able to make her own. So what is a class? Well, I think the easiest wave showing you would be to just give you a quick example. We're gonna create class called Animal. You can see instantly the split between job before marching and C plus performance and high come from a simple background. So we put each of our new brackets on a new lines of the lineup. Him. Java. You tend to put the 1st 1 on the end of you first line and only put the end one on the on a new one. But I'm from c++ background, so I'm comfortable doing it. So you create a class would create a classical animal, and what class will allows to do is create objects of this animal. So we've defined an animal when we could make loads of different animals with different attributes. Eso I'll start off by creating a name for it. So let's just give it a name. And let's think what else an animal might have. Well, it might have a freed and certainly haven't age. Ah, Beau Welles color. Yeah, there's color will be a string. Ah, striped And I could be able actually, some use bulls. This is hell to enter over that. I'm off to, uh, with a capital B. Let's forget about bulls from? I don't know. I'm getting around. Come back to it, Ben. Right there. We've got four Trib. Use a lso pin, this animal class. Now what we've what we can do is we can go back into a Mame and create an object off the animal. So what we have to do is tight. Um uh, class nine. So no, I've got to give a name to this animal. I'm not talking about this string name here. I'm talking about a name for the object itself. Was gonna call the animal one for now equals new. Oops, I'm in low, So we created out object off our class animal. We've called the animal one. So animal one is the object. Animal is the class. If you've never done any work on classes before, then your brains probably a bit confused right now, and they will clear up clear for a lot faster if you have some have ago programming it in your own time. But now we can access. Now that we've created that object here, we can access its attributes to do so. We just type in object name. It's their animal wall, and then duck you see, we've We've put full stop here. Let's start. I think this is a list of all the public attributes the and we can access. So we got aged breed color name s also offer names. That's how we listed it in the class. Let's just say fluffy. We'll do the same for the other attributes. So breed a lot at night. Dog, remember, this is a string. So you've got to use our quotation marks. I'm in. My one age equals seven years old. Ah, And then And he is around. They were going to create a new object Animal animal, one of class animal we'll give you this is May times we want if wanted another one We just have to call it something else. Get them re Seems like a small animal. Wrong now. Not much to reading it, but I'm sure it's all right. Just lost all meaning to me animal to will call it New Animal. And I am We just got to give it a little its attributes again. So this one could be called scratchy. Ah, cat nips That was the last one color. Ah, after night gray and they were having with grade two separate objects. Animal one animal to off the class. Animal. Um, I'm gonna leave it there for today's video, but I'd really just want you toe have a practice with these and get in into your head that this is an object. This is a class. This is an object off this class. Simple, once you do it off of them. But for now, I imagine it's quite confusing. We're gonna do a fair few videos on classes low, so I wouldn't worry about it too much if you don't get it straight away. 3. Classes - Classes and Methods: So the end of the last video we recovered well, classes. Uh, the moment they didn't really do anything. We've create these objects of animals. Create a dog named Fluffy. Okay, a cat named Scratchy. Does this say they don't really do anything? At the moment, we have a little this information, but if we run the program, that airport is blank. You know nothing's coming for you. How do we access this information that was creating these objects? Well, we got a number of ways if I come below this object here, and I'm just gonna output the name of our dog Fluffy here. You could do that by using the same old system print line. Ah, command followed by object. I'm just accessing it with the with the full stop. So basically the same as we did appear. That's where not we have put fluffy, Simple, simple, simple, simple. I'll show you what happens if we try not put it up here. Obviously, we haven't set name toe anything yet, so it just comes out with No, it doesnt calls an era, doesn't crush the program and horribly ruin your day. We initialize the name down here. We don't initialize it to anything, so it just becomes No, that's last one. No means it means exists. But it doesn't equal anything came by in mind for future events. Knows we can initialize thes things down here in class. Animal We can initialize it eso weaken Set the color to be other my black So it's a default black So let's run the program, Nofal face we all good s get rid of that warm instead off our bring name Here let's output color. You see it still Outpost brown. So we set the color to black down here in class animal But as we initialize it, we override it here we set Fluffy's color to be brown. If we output before we override it, then it's gonna work exactly same. See Black brown. So before we before we override it, Fluffy's color is a default black after we override it, Obviously it becomes brown. Okay, so we've figured out how to access the information, but same as in the function or method lectures, we were able to create functions below the main our own functions. We could do the same in our own classes so we could create functions the belong to class animal. There will only be accessible when we have an animal objects. So I'm just gonna create a function that will allow the animals to this describe themselves . So we know after put the system outline, we don't have to write that. If we want to access something, we can just call the function and he will describe themselves. So let's do that. I'm gonna create one cold water. Ah, describe. Seems like a good enough name to me when all this is gonna doing is it's going to talk about itself. So it's going to say hello. My name is welcome, Captain. A name on the end. So let's try and room this. So how do we have you think we're gonna access this function here? You want, pulls the media, have a girl like yourself You're welcome to. But I will tell you now we're gonna call exactly the same as we called our variables. It's got, say, animal one. Don't what I call it Describe no one one in the out look alike. So I don't blame me. There we go says hello. My name is fluffy because it's saying hello my name is plus name. Obviously, let's try calling it again before we initialize, too, Fluffy says Hello. My name is no still looking exactly as it did before. We don't initialize name to anything, so obviously it's just going to say no sample. Simple, simple. It's let's just expand on. Describe beginnings, I said, describing not name. Ah, I am, uh, age years old. So I've done this before. Ah, there I'm listening. Plus, I really don't like encounter banks. It gets a bit confusing, but once you've done it once, you can just keep it the same. So again was going to animal. One dog describe it comes up there with the dot really useful that they would go. We can use the exactly same on animal to, in case you were wondering, maybe get of them. So this described function is its operating on the objects, not the class itself. So you might expect described to come out with, you know, fluffy and seven years old. But it's is is looking animal to, And then it's looking specifically of the values in animal, too. I know it can be a bit confusing to get your head around, but is this is the essence of job Java programming. Java isn't object orientated language. And so you have to get your head around classes because they are the most important thing. Sella's suddenly in the last video. We're gonna work on these for some time, so don't worry yourself. 4. Classes - Public by Default: So another interesting point about having your own classes is when we have these variables defined here in the class that public by default, I'm going to go into quite well by means yet public, private, protected. But it is a thing. I just wanted to know that by now there is a thing that these variables are public. But what does that mean? In essence, let's go back, Teoh. One of the methods we created a few lectures previous. I believe it was something along lines of in birth year. Cal kill a birth you. So something along that long, which would take in the int age clips. Um, they had taken the ent Age on, then return. What? Yeah, they were born in roughly. Without Without the months, obviously. So let's do that. Uh, 2016. Take a judge. If we were amount here than the animal to door click birth year, I would have to input the age here so we actually have to input the age. So the animal two dot age we just write in their lineup. If we were in that, then it's gonna work. Fine. Ah, no, we never actually output. That's gonna be a long lunch. The out of print line it works. Fine. Um but that's how we did it in the previous lectures. It's not necessary when you have thes public variables appear we don't have to pass in the age here. So if you take that line out, then you see very clearly Let me just select breed or something. The age here is in black form, okay, for take out the age that I'm passing in. Then suddenly this age refers to age up here, which is found as a class variable. Because this is public, our function I method down here, conceive that. So we got this therapy X for passing in age into the function, but that's not necessary anymore. Now, if we run this again, I'm gonna get exactly the same response. We get 2012. But instead of passing in, um, variable, it gets it directly from the class. Now, this isn't necessarily a good thing. We'll be covering that in future lectures. But I did want you to note that it waas possible because specifically, these variables are public by default. 5. Classes - Getters and Setters: So the end of the last lecture I told you about, uh, these variables being public when you first declare them That's not something we particularly one generally, when you create new, classy one as many variables as possible to be private by default, obviously the public by default that you generally want them to be private if they're old public than everything will be able to see everything. It would be really inefficient. Just be bad program and in general. So to define a private variable type in private in front of simple uh, You see, now we have some errors created, namely, saying name is proper access in animal. I wasn't sure what the error. So to get around this, we have to access this variable with functions esos create one used to have what string get name. Well, that's going to do is return name now? If we wanted to print name, we'd have to call the function animal, too. Don't get name and all that's going to do is look at what we've set name, too. On print out. We use the return function so it won't actually print out. But you know what I mean. it fetches the name. Obviously we can't set it like that. We went out to print out. We haven't set it yet. Eso we need a very similar function. That's just gonna set name on these types. Functions are known as setters. I'm getters, tryouts talking type of the same time. And all that's gonna day Izale is allowing users to set the name. So that's gonna take in a string that little one just returns it so we don't need to take with them. This is gonna take industry. Let's take it in string, not tonight and put And then name is going to be equal to input. Pretty simple. A little bit of America. I wouldn't returned anything. Ah, yes. Makes avoid them. It doesn't need to be a strength. This still isn't gonna work because we're trying to access it through the doctor here. Obviously, it's private eye doesn't work. So to get around this, we have to set the name as such, No one just coming out that line. So it's a little bit of a Pfaff. But you want your variables to be private. Oh, and obviously Ah, well, just get it as well. Oops, see what happens. Oh, I didn't actually print. Now you did it. That are That should be fine. Probably. Maybe so. First, Wolfie, there is it being printed out. So we snow set the name with set name Filipe on we retrieve it with get name. So this may look a bit strange, I suppose. But the idea and object oriented programming is you need to keep your valuables private. If you don't, then everything will be able to see everything and it's it's inefficient. It'll get confused and lay down line when you've got 20 different objects and the different classes exact er so we try to keep as much private as we can. I'm. But if you know something needs to be public, then levers public or better yet declares public, so everyone can see there's public. Um, be generally want to keep it private. Any times you want a variable to be public is you say you want the user to interact with it and be able to change it. If it's private, then it generally won't be changed by the user that we changed in the background by the program on that we accessed through class functions, but the user generally won't have much interaction with it. So using name is the example that was probably about about the high idea, because that's most likely gonna be changed by the user. You know, you name your pappy, don't you? Can't change its breed is what I'm trying to get across. Well, look at constructors in the next video and show you how to essentially self defaults like we've done here, but threes of a constructor. 6. Classes - Constructors: I spent a little bit of time refractory the code here or re factoring once a forget so seeing a refreshingly factory essentially just means cleaning up the code. In the last, I added a few different variables that I thought was applicable to animals. Eso got only here. It's not necessarily an animal type this. We get the lines, get blood. But each animal probably has an owner. If they are a pet, which is the other variable, I don't No, there is a pair is also a Boolean type bully ins can only be true or false is just the English words true or false? S a pretty simple next thyself instructor. I'll talk you through what constructor is. So constructor is unique. It's a function or a method. Um, class doesn't need to have one. But if it does have one than it's got feed properties, you've got to be aware off eso Constructor sets up the default values for a class foreign objects anyway, so previously we have it like the color was black. I believe it Waas. We just set it up in the variable itself, which is fine. It's valid, but it's much cleaner to do it through the constructor. So we set up a construct here, know that it doesn't have a type, so it's not avoid or in into or whatever. It doesn't have a type fell to do that. Then it will calls Errors s I don't have a type. And then you see, here we taken three values and we just set up a private variables. Two. If we pass in, where we passing in? Well, up here where we declare our new animal one objects. Ah, we were, you know, animal animal. One equals new animal. And then we passing these three values. Here's a feudal five block that's just breed age color. And then we set the private variables to have we pass it. So that's how you attached default values to your Ah, no default values. That's how you attach values at the start of an object. I suppose you can still sell default Molly's if you're so inclined, um, appear these will be over in by the constructor. In this case, if you weren't passing it into a constructor, Say is a pet said that false by default, and you still doubt the that is bad to do it through the constructor. I'll leave us false. Anyway, I also reused that gas and says I introduced last lecture. Probably Onda. Obviously astonished returns is apparently just return. True or false? It's a Boolean type. It was just avoid takes in a bull on sets. It was a pep, easy peasy. So this is a public variable. I don't need gas and says for I could just access it through. Um, yeah, I see you see ourselves Gazza says for and then quickly changed my mind. Uh, this I'm gonna keep This is a public variable on dso Just access that through the old Ah, as so only the same for the owner. What do I have? An error? I'm gonna leave it because I'm not sure what the problem is. I'll leave it for now and then I know we could do the same. Ah said to me, Why not? Not quite sure why I'm getting these areas here kind of find symbol. They'll public so we should have access over them. Uh, declaring wrong onto Yeah. Yeah, Not that. I know Life a little functions. That's how accept public variables bit too much C plus plus on them until nothing is probably different in that as well. And the last one we have is get is a pet we say is true. Ondas such we could set the owner toe. Harry, One more check quick again. Here is we could set the owner through, says a pet. Um e well, we could do a little check. If is a pet do you don't need those equals false and I don't know Um oh, no, he cools no pounds something along that lines. Anyway, you get the idea the If we set this is false, then we can't set owner to anything it is. I'm probably much clean a way of doing that. Um, which I'll have a think about actually like me task. Think of think of a way to clean that up. Ah, that way of cleaning that it will probably be through a method. So if is a pet is false, then you know, set owner equals No. However, however, if is a pet is true. Then owner will be set to user impulse something along that lines. So, in the next lecture, I think I'm gonna introduce base classes or we'll start Java inheritance. And so I believe it's cold in Jovel and see if classes and stop classes. That's it. Yeah, yeah. People suppose ical based classes and child classes. I'm a bit rusty. Ill. This whole animal example make a lot more sense after 7. Classes - Organizing Classes: I get in quick, clear with a show you how to spread out your classes over multiple files. It's probably some fashion it on the style of class section. The moment we've been working in one file. It's just the one I created, The very start. The course, in fact, is eating Hello, world or Joe? Um, obviously, any final project or whatever you do, you want the constantly to be something a bit more, uh, relevant. Obviously, you didn't. Hello. World was just because the first program that we were it was have a world on dime to keep it for now, for just just for keep it simple. But obviously, in yours, uh, make it relevant. So it's just are having more, more classes you'll have to create create new files for each class. This is a staple of job program, and not so much in other languages, but in Javi, generally career new page for each class. And that's why I've done you see here. I just took the code hoops to the code from the animal class and it was created. You file a little Jova exact same code. I believe this is a public class now I think you usually say class animal, but obviously classes public by default. I just took all the code and paste that into here, uh, is is blanked out the moment. So another reason that is the same carrot. I can promise you that. So if you want to create your own file, he simply right click on the eating Whole world Source package. New Jova class. It's going to create a new, um, file, No page or tab. However, however you want to refer to it, just call us one cap for the sake of simplicity on day would have. It just creates any any file Cattle Joe accessible yet basic Sawyer office. There's no public classless and I mean eat me Hello World file the the rest of its here Scared of this Teoh make it bit cleaner, and we'll be working in these files in the future. But it is important to note that their deal on track together just fine if I'll take these are shameless that working this This was honestly something that confused me a fair bit when I started working with Java spreading echoed out across multiple files. It's really not something you do too much and safely plus, or you can work around that just fine. You know, one of two different files and and you file for each classes. Quite alien in C plus. Plus. So this was something that stumped me, but so I figured I'd dedicate lectures to it. But I do want to show that the code. Uh huh. I was going to say rooms. Fine, apparently. No. No. Ah. Says, um, Gunnar's that. Ah, this is money. Yeah, it's fine. It's working. Fine. It's in my new class here. Uh, I'm ransom Karen, though, which I'm keeping secret until the next lecture, but yeah, just know that across what we've done already. An animal. And you know how well this is all interacting together just fine. So you don't know where is spreading out across multiple files, and it's good practice to do 8. Classes - Inheritance : So in today's lecture, we're going to becoming inheritance. Inheritance is it's quite an advanced job of subjects. I'm going to be around the bush. It's it's very integral to Jeff program, however. I mean, it's not. It's not quite the step for that. You took up two classes. In general, classes really are the basis of objects or intake program. Inheritance is a very useful Adam. Well, it's not completely necessary. Still, we're gonna be covering it because it's really good program. And I generally think it's Ah Howard should be doing so. I've cleaned up the animal class yet again. I want to say cleaned up. I mean, simplified. In this case, I've turned these about public, which they shouldn't be. I'm just doing it first. Simplicity sakes. I don't need a dozen gas and says in your program, I wanted to keep as many of these privates possible because it is just good programming. I'm just doing it for simplest a sake. I've also done that one function which is eat. It's gonna print eating. So if you go back into our unit, we have a world here. We declare our new objects animal one, its object off animal I was gonna do animal eat, Am I get He just prints out eating as it should. This is nothing new, but this animal is an example of a super class, as it's known in Java in simple, supposed to come from that, it be known as your base class. So what based classes is kind of the essence, the essence of what your objects meant to be. So an animal is a very generalized term. Essentially, adult is an animal, a cat as an animal, a horse is an animal. Whale is an animal. Um, it's a general term. If we want to get more detailed than what we do is, we would create sub classes, which I've done here say CIA have created Dog Dodger over so public class dog extends animal eso. This is obviously different from how we declare that animal class we just created public class animal. Ah, this extends animal bit, tells us that it's a subclass of animal. I mean, it's in plain English, but it can be a bit hard to comprehend. So the thing you need to know about sub classes like this, it has access to everything within our super class. So our subclass dog has all of these attributes and all of these functions. I know it could be a bit complicated at the moment, but I'm going to show you. So instead of creating animal equals animal warm off the super class we're going to created of our dog. So he's gonna have a dog. Ah, Doug, one you don't and I will have no Cuando e they see is still Prince eating. That's the significance. It tells us that even though you know all that code is written an animal, our dog class has access to all of it. So when we call eat on dog one, we're getting access to our animal eating. Uh, that's a super super simple like I usually do, but it's not so simple, I suppose, Um, we're gonna be covering it over the course off a few lectures. I got time to explain about all year. Only at four minutes we'll keep going. So the next thing you need to know about super classes of sub classes is although the subclass has access to everything within super class, the super class certainly does not have access to everything in the subclass. This is important. It's It's a hierarchical structure, you know? It goes from down to bomb. Everything at the bomb has access to everything above it. Ah, but animal at the top does not have access to everything below it. That's the best way I can describe it. I think so. I'll just create a function inside of a dog which is just gonna bark. It's just gonna print how simple line. So now if we want to access this, which is type in dog one dot book, we run that cool. We got eat in, we got wolf. That's the older that we call them in. So let's try this without animal class. So animal animal one equals new animal. We follow in so far. So we can you animal wonder eat just fine. Ah, this is It's an animal method, so animal one will have access to it. See, there are no third line of eating, but if we try to do and then we'll one don't bark hoops. I'm getting an error. Why? Why do we get there? We cannot find symbol. Variable animal woman type. That's the location. Simple method box. I can't find method bark. Essentially. Ah, this is just because we declared method bark inside Bible class instilled inside of our animal class. Under such, we do not have access to it from an animal object. 9. Classes - Abstraction: So some of you more eagle eyed viewers will have noticed in the last lecture that created to some classes, the second being capped, not Java. I never actually went into it, but maybe spotted along the top here. Ah, this one just says me out similar to the dog, one said. But this one says, May I just want to do is to demonstrate that our dog will not have access to our cat. Ah, functions or methods we can't do dog one dog for me out. So I think of dog and cat as on the same level is, ah, hierarchy that we're discussing in the last lecture. Both have access to our animal methods, but neither have access to each other's. So I feel a simple concept. Ah, dog, count me out on a cat can't bark essentially what I'm getting up. The real meat of this electrical it's getting, too, was obstruction, Um, obstruction. It can be confusing. Concepts begin with, but it's really simple. Once I give you a code example. So obstruction means that we created an abstract class or method, Um, when we create an abstract class or method, it means we cannot make an object from it. I know that makes no sense of the moments. I'll just I'll just go ahead and show you. So if I was typing abstract here, we can no longer implement Animal has its own object. So forget about two. Are you to me how the world see analyst abstracts cannot be instance she ated so we can no longer credit Animal one. For example. We can no longer create animal 23456 If we create an abstract class, then we have toe implement all this through sub classes. Um, I honestly don't see the use in abstraction too much because it's essentially limiting what you can do. You can't create bare bone classes anymore. That such as animal, you have to do it'll through dog cat bird. Except for three sub classes. Um, and that's Satel Abstraction is we could do it through eat 00 methods Should I say so? If I was to make eat an abstract Ah, abstract methods cannot have a body. Oh, yeah. So you can't actually implement anything? Obviously I have to just declare it like that and then we would implement our eat function . Ah, ticket executive meeting today. How? Because I called eat here. Probably. I'm just gonna ignore by era. For now. Until that, we'll cover the means. Um, it's Ah, let's trying implement our eat method. What was that avoid? Yeah, Well, Mr Well, public void. Eat. And then it was something along lines off Aleppo last time. And so the reason you have an abstract method is you'd want it to be different for each subclass again. This is not necessary will cover it in the future, but it's not necessary to have abstract classes method. Sorry to differentiate between the sub classes. Let's say a dog scuffs his food while the cat tonight picks away. It'll something. I got the same error here because we didn't implement Eat. Ah, so this could just be out tonight nibbling. So let's call eating again. Don't wander. I'm a critique as well. So it becomes cat one. Never have it cool. So we called dog Wanda eat. We get scuffing. We call cat one, but you will get nibbling eso again. That's obstruction on methods. Same as we did with the animal class. We can no longer call eat from animal itself. We can no longer initialize it in animal itself. Just the Claytor is a a method that both of these sub classes must have and then we can change it in each of them. It doesn't need to be abstract for them to be changed. However, at least it doesn't n c plus plus. Maybe I'm talking out my arse e That's just to clear is ah, we don't need We don't need to be abstract. We just got them. What does that keep out there? Thank you. Eso will just set up a default of eating. Well, you anything in here? So if I could just cheat it with the clipboard that you get, uh, was have eating and then get rid of this one in cat on, we'll see what happens when we were on it. Get rid of the me on the Bach to simplify. There we have it. So, d c. What's happened there in animal? We set the default of eating again soon Abstract class, but we got rid of the abstract in the method. So it is now a default that's being passed down to dog and cat. He just says eating dot, dot, dot However, in dog we decide we don't want doctor, just say eating the liver. We want a dog to scuff it. So we put scoffing dollars. So we've overridden our eat method. Hell, no longer say eating. When we call that from a dog object, he'll say scuffing in the cat. We we forgot to do it or we didn't bother. We thought eating was, ah, a valid description of what it was doing. So we just left. It is eating way. We never bothered overriding it. And as such, it just prints out eating. Um, so, yeah, abstracting classes. I can kind of get Ah, because simply put, you may not want the base class like this. It's that maybe it's a bit too simple. It doesn't do enough the abstracting methods. I don't really see the point off because you can already pass it down. You don't have to make changes to it, and you can set up a default. If you abstract a method, then you can't declare a default and you have to set up in each class. So abstracting classes go for it. Not something I personally do, but you're more than welcome to abstracting methods is something I would avoid. If you see the use of it, then feel free