Best Answer · By JanBask Salesforce Expert
Answered on Dec 7, 2019
Encapsulation acts like a protective wrapper that prevents code and data from being arbitrarily accessed by other pieces of code defined outside the wrapper. This is one type
of mechanism that binds together code and the data it manipulates and ensures it's safety from outside misuse.
Let's take an example from the real world scenario, consider the automatic transmission on an automobile. The hundreds of bits of information such as how much you are
access rating, the pitch of the surface you are on, and the position of the shift lever. So We as a driver, have only one method of affecting this complex encapsulation
: By moving the gear shift lever. We can't make any difference in transmission by using the turn signal or windshield wipers. Thus the gear-shift lever is a
well defined (indeed unique) interface to the transmission. Further on this, what occurs inside the transmission does not affect objects outside the transmission.