What exactly is the purpose of encapsulation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

What exactly is the purpose of encapsulation?

Can you give a relevant use in a program as an example ?

4th Apr 2019, 4:04 PM
SWETA X
SWETA X - avatar
7 Answers
+ 14
Where are get and set methods used?
4th Apr 2019, 6:02 PM
SWETA X
SWETA X - avatar
+ 9
Thanks for the answer, JavaBobbo !
5th Apr 2019, 2:03 AM
SWETA X
SWETA X - avatar
+ 3
The get method is used to return the value and the set method is used to set the value later on in your main method. There is comments in the code read it and you will understand👍
4th Apr 2019, 6:09 PM
JavaBobbo
JavaBobbo - avatar
4th Apr 2019, 7:12 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
It is when you use get and set methods, i got a code which explain it: https://code.sololearn.com/cpAdKz68c2j5/?ref=app
4th Apr 2019, 5:19 PM
JavaBobbo
JavaBobbo - avatar
+ 1
You are welcome👍
5th Apr 2019, 6:03 AM
JavaBobbo
JavaBobbo - avatar
0
I will say it's for identification and easy access
11th May 2019, 8:07 PM
JAMES ADAKOLE
JAMES ADAKOLE - avatar