Object oriented programming (OOPs) is based on concept of “Objects”.
Object is real entity of class, or we can say it instance of class. object is collection of attributes and behavior. For example, a dog is an object and its attributes are like as color, name, breed and wagging the tail, barking, eating are the behavior of dog.
There are three mechanism of OOPs concept, that help us to implement the OOPs model.
Encapsulation means wrapping. And as it name says, it wraps the data (variables) and the code (Methods) in Java. It prevents the data and code from being accessed by the code that is defined outside the wrapper.
If we relate it to real world let suppose you have a car and you want to go some place then you only press a start button or use your car keys to start. there is no need to know how the internal things are working to start. so we can say all internal processes are encapsulating from you. And process of starting car doesn’t affect the other process of car.So we can say that all the process are encapsulating from each other.
Polymorphism means many forms. It is a feature of that allow general classes to use one interface for their actions.
For example : Animal is a interface that is not a real entity. It have ‘age’, ‘Sex’, ‘weights’ other attributes. That are used by Labrador and other entities.
It is the process of inheriting the feature of one entity by the other real entity. Inheritance is the concepts of hierarchical classification.
( Figure : Inheritance )