I need help on classes and encapsulation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I need help on classes and encapsulation

a detailed paragraph and a code will be helpful thanks!

8th Aug 2017, 12:57 PM
1 Answer
as far my understanding of this question u want to ask that why encapsulation is important. isn't it? so suppose a member is private, u cannot change without setters. now suppose u have a program in which u need even number inputs how would u determine whether input is correct or not. Using setters u let ur values go through a doable-list to check whether it is correct or not. U can define whether how u want ur values.
8th Aug 2017, 1:12 PM
shobhit - avatar