what is difference between properties and encapsulation | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

what is difference between properties and encapsulation

In encapsulation, we access the private field using the public method. In the properties, we can access the private field with (set, get). What is the relationship between properties and encapsulation? And what is the difference? I think we use the functionality of the properties in some way in encapsulation, but what is the difference between them and what is their relation? It seems a bit vague for me

23rd Sep 2023, 3:04 PM
safir safir1
safir safir1 - avatar
1 Respuesta
+ 2
Properties are known as variables of different datatype which stores value. Properties value can be change from outside if you make them public so if you don't want that anybody can change value you have to make them private and private variables can only be access through Setter Getter method which are public and known as Encapsulation.
23rd Sep 2023, 4:34 PM
A͢J
A͢J - avatar