+ 2
Data encapsulation means you keep the variables strictly to its own class. For example, if you have a Car class with an engineBrand string variable, you want a Driver class to use the car but can't modify this. Encapsulation, on the other hand, allows you to keep methods "as they are". So you can extends ie. a Engine interface with a StartEngine function, and each Car, Plane, Ship, which implement this interface, can StartEngine, no matter what it does. Think Encapsulation as a black box, with (optional) inputs and outputs. You only need to focus on this inputs and outputs, the rest is done by the methods
18th Feb 2018, 3:44 PM
Hugo Puyol
Hugo Puyol - avatar