6.1 Intro to Encapsulation
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 »

Video Transcription
00:00
hi and welcome back to the course. I hope you guys are doing well. And if you remember in the last video lecture, So in module five, which is essentially just a single video, we started to dive into this idea of object oriented programming which Java is all about and the components of old P
00:18
and those components as we discussed our
00:21
encapsulation, abstraction, inheritance and then finally polymorphism. So in Model Six, we're gonna be starting out with encapsulation, and we're going to see what encapsulation is about. Soto list out the learning objectives for this or for today's video lecture,
00:38
where first gonna be understanding a high level idea
00:41
of encapsulation and what it exactly promotes
00:45
as well as what it entails. Then we're gonna move on to discussing some of the advantages of this old P concept.
00:53
All right, so let's dive right into it. So what is encapsulation now? If we start out with a formal sort of definition which we have done in previous models, encapsulation is essentially just a mechanism of wrapping data, so variables that we write in the program and code. So for something like methods or functions that
01:12
at on that code
01:14
together as a single or a singular unit
01:18
and in an encapsulation, the variables of a class or hidden from other classes. So whatever you do in your encapsulated class is hidden from any other classes outside. And those attributes, or those methods or functions, can only
01:38
be access access through something like
01:41
get her and senator methods, which we will discuss
01:45
now. Encapsulation often is referred to as a data hiding, and it completely makes sense because that is exactly what it is about. And you will see that in the lab that we will be doing shortly after this video.
02:00
All right, so let's look at the elements required to achieve something like encapsulation. Now there are two core and elements you need to take into consideration when trying to go for this idea of encapsulating the data and the methods in your costs.
02:19
So, first you would declare all the variables of your costs private or the ones that you would like to declare private,
02:27
Um, And then what we need to do is we need to create a corresponding gather and center methods which will allow us to modify thes private attributes even outside our class.
02:42
And that is essentially the only way we can access these private attributes, since they are not otherwise available for other classes to modify.
02:53
Okay, So if we move on, what are some of the advantages of
02:58
encapsulation? So first, it provides coat security through data hiding, which we just just discussed, and then reusability you can continue to reuse your code and finally, flexibility. So the ability to make something read on Lee or right on Lee.
03:16
Okay. So just to summarize our video lecture today, we went over it. The idea of encapsulation and what it entails, as well as the advantages of encapsulation.
03:29
Now, in the video coming up next or in lap coming up next, we're going to be creating a student profile, and we're going to see how that relates to or how that connects to the idea of encapsulation that we just discussed.
03:45
All right, so, as always, if you have any questions at all, feel free to contact me via Lincoln. And I would be more than happy to answer any of your questions. Thank you very much for watching. And I look forward to seeing you in the lab
Up Next
Similar Content