What is encapsulation?It is the fundamental principles of object-oriented programming. It hides all the internal details of an object from the outside world. It hides its data and methods from outside the world and only expose data and methods that are required. It provides us maintainability, flexibility and extensibility to our code. It makes the fields in a class private and providing access to the fields using public methods Encapsulation allows us to create a "black box" and protects an objects internal state from corruption by its clients.
|