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 *

Already have an account? Sign In »

4 hours 19 minutes
Video Transcription
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
and those components as we discussed our
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,
where first gonna be understanding a high level idea
of encapsulation and what it exactly promotes
as well as what it entails. Then we're gonna move on to discussing some of the advantages of this old P concept.
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
at on that code
together as a single or a singular unit
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
be access access through something like
get her and senator methods, which we will discuss
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.
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.
So, first you would declare all the variables of your costs private or the ones that you would like to declare private,
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.
And that is essentially the only way we can access these private attributes, since they are not otherwise available for other classes to modify.
Okay, So if we move on, what are some of the advantages of
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.
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.
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.
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