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 *
or

Already have an account? Sign In »

Time
4 hours 19 minutes
Difficulty
Beginner
Video Transcription
00:01
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.
00:12
So, as always, here are some learning objectives.
00:15
Understand what classes are? We're gonna be aiming to, uh understand also why we need to use classes
00:23
and how we can essentially create classes.
00:28
So what are classes to begin?
00:31
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
00:50
instances of that class.
00:52
When you instead she ate a class, you create an object that looks and feels like other instances of that same class
01:00
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.
01:18
Essentially, we've we've worked with classes in the first marshal, we didn't really die of deep into them.
01:23
Only class is is it's a template.
01:26
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.
01:45
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.
01:56
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.
02:09
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
02:29
to build those bikes are essentially the same right,
02:32
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.
02:49
All right, so here's an alternative definition for a class,
02:53
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.
03:05
Think of it as a template or blueprint
03:09
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.
03:29
All right, so here is an example of
03:31
in Stan Sheeting or started creating a cloths. So this class is called vehicle and it has,
03:39
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
03:59
a method called Run.
04:00
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.
04:13
All right, so in this video, we discussed what classes are in Java,
04:17
why we need classes
04:20
and how we can create classes. Now, just before we finish off, I'd like to elaborate on the second bullet point here,
04:28
classes allow us to use Ah,
04:31
a
04:32
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
04:51
if you feel
04:54
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.
05:12
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