+ 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
1 Resposta
+ 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.