2.1 Introduction to Classes

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »

4 hours 19 minutes
Video Transcription
Hi and welcome back to the course. Now, in the last video, we wrapped up Marshal One. And in this video, we're gonna be talking about classes, which is the beginning of module two.
So, as always, here are some learning objectives.
Understand what classes are? We're gonna be aiming to, uh understand also why we need to use classes
and how we can essentially create classes.
So what are classes to begin?
So this is official definition from the job of documentation website, which I will put in as a link in the supplemental materials. So here it says, the basic building block of an object oriented language such as Java is a template that describes the data and behavior associated with its
instances of that class.
When you instead she ate a class, you create an object that looks and feels like other instances of that same class
that data associated with the class or object a stored in variables. The behavior associated with a class or object is implemented with methods. So now this might seem very overly complicated and a lot to take in, so I'll break it down for you.
Essentially, we've we've worked with classes in the first marshal, we didn't really die of deep into them.
Only class is is it's a template.
It's a template or a blueprint. And you, once you set one template or a blueprint, you can make copies of that same blueprint, which in this case is called a class. And then you can use those copies in different parts of your program.
Another example I'd like to give is in the real world, you often find many individual objects of all the same kind. There may be thousands of bicycles and existence, all of the same make and model.
Each bicycle was built from the same set of blueprints, blueprints and therefore contains the same components in object or into terms. We see that your bicycle is an instant of the class of objects known as bicycles.
Yet again, a class is a blueprint from which individual objects are created. So this example is saying that let's say we have thousands of bicycles, right, and each of those bicycles are of the same make and model. But the components and the tools that you use
to build those bikes are essentially the same right,
so that is what it's saying. The blueprint of creating Ah, a bicycle is the same. And then every unique bicycle is its own individual object in Java or object oriented terms.
All right, so here's an alternative definition for a class,
so this is much simpler and broken down into two lines. Essentially, it's the design of a type of object, specifying what state and behavior the class has.
Think of it as a template or blueprint
and an object. If you have not encountered the meaning that is a duplicate or copy of the class. Now we won't be diving into objects yet because that is a more advanced topic for the modules that will be following after that. But I'm just going to give you a high level overview of them.
All right, so here is an example of
in Stan Sheeting or started creating a cloths. So this class is called vehicle and it has,
uh, three variables. One is ignore the private for now. We'll explain that later. But that one is called Doors, which is an integer as we saw some examples in March of 11 is called Speed, which is also in danger and then you have string, which is just characters or a sentence. And there's a variable called color and then
a method called Run.
So this is basically how you create a class you could give it. Any name does make sure you start with a capital letter like it starts here with V as a vehicle.
All right, so in this video, we discussed what classes are in Java,
why we need classes
and how we can create classes. Now, just before we finish off, I'd like to elaborate on the second bullet point here,
classes allow us to use Ah,
template or blueprint, As I said before and built in functionalities that we have written once and use those functionalities without writing all of them from the beginning to the end. You just have to make and make a copy, which we call an object. You'll find out many things as you go on in the course. But
if you feel
a bit confused, sir, you some some parts are complicated in your mind right now. That's completely fine. And programming that happens all the time. But we'll be going over this in a lab and in much more detail. So yep, that's it for this video. And in the next video, we'll be going over class constructors in Java.
I know it's always if you have any questions at all, feel free to connect with me. And I would love to answer any of your questions. Thank you very much for watching. And I look forward to seeing you in the next video.
Up Next