Encapsulation and Polymorphism


Encapsulation
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. Other way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield. Polymorphism
If one task is performed in different ways, it is known as polymorphism. For example, a salesman may draw something (such as shape, triangle, rectangle, etc.) differently to convince the customer. In Java, we use method overloading and overriding to achieve polymorphism. Another example is to speak something in different ways; for example, a cat speaks meow, dog barks woof, etc.

Coupling
Coupling refers to the knowledge or information or dependency of another class. It arises when classes are aware of each other. If a class has the details information of another class, there is strong coupling. In Java, we use private, protected, and public modifiers to display the visibility level of a class, method, and field. You can use interfaces for the weaker coupling because there is no concrete implementation.