What does encapsulation mean? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 131: What does encapsulation mean?
Рекомендации по теме
Комментарии
Автор

And reflection in java spoils it all 😜

bartek
Автор

Ok, but if I have just simple getters and setters for all fields in my class, how is that different from public fields? I know that it gives me ability to modify the accessors, but in most cases it's not the best idea and you can just start using the accessor then.

rzyr
Автор

The purpose of Encapsulation is protect the state of your object to be corrupted unintentionally by peer programmer as it was very often with procedural language like C which uses global variable... So use public method to access/mutate the state of an object

RAVINDERSINGH-htpl
Автор

Been thinking about lately how would I explain encapsulation in an interview and this comes tnx

angeloalonzo
Автор

Ok, if encapsulation is only about private accessors then how do we name "Bundling relevant state and behaviour together" to create an object. Mind you - this is the most fundamental idea of OOP.

TargunYssboern
Автор

And then people just create getters that return the private list object and spoil it all.

brixomatic
Автор

Then what is abstraction. This is definition of abstraction.

sush
Автор

Eventually they have included subtitles to videos 🙌.

hazartilirot