上QQ阅读APP看书,第一时间看更新
Encapsulation
Encapsulation refers to the hidden nature of an object's data components. We know that the data is there, but cannot access it directly because external entities cannot directly interact with that data:
Inheritance examples
The illustration above demonstrates how a Bicycle class protects its data from external methods and functions. The object's own methods are the only mechanism that can directly view or alter its data.