In Chapter 13, you learned how objects were created from classes and how classes define properties and methods. To protect its data and methods from other parts of a program, an object isolates or encapsulates its code. Encapsulation is one prime advantage of object-oriented programming because it creates self-contained code that you can easily modify or replace without affecting any other part of a program.
By keeping code as independent as possible from other parts of a program, objects increase reliability. Think of a house built out of playing cards. ...