Table of contents
Four Pillars of object oriented programming are ->
Encapsulation
Polymorphism
Abstraction
Inheritance
Encapsulation
The wrapping up of data and operations / functions into a single unit (called class) is known as Encapsulation.
It is a way of combining both data and the functions that operate on that data under a single unit.
Data and its functions are encapsulated into a single entity.
Encapsulation is more often achieved through information hiding.
It is a way to implement data abstraction. Encapsulation hides the details of the implementation of an object.
Polymorphism
Polymorphism is the ability for a message or data to be processed in more than one form. It also means "one name many forms".
It is a property by which the same message can be sent to objects of several different classes and each object can respond in a different way depending on its class.
Function Overloading is a concept of Polymorphism . Multiple functions defined in the same scope having the same name but differ in arguments passed to it (number of arguments or type of arguments).
Abstraction
Abstraction is the concept of simplifying a real world concept into its essential elements.
It refers to the act of representing essential features without including background details or explanations.
Abstraction can be achieved by using access modifiers in a class which restrict the access of different data members to outside world.
Inheritance
When one class derives the properties from another class it is known as Inheritance.
One major advantage of Inheritance is Re usability of Code (with inheritance we can Re use the code which means we can access other class members without even declaring it ).
Run time Polymorphism is achieved by Inheritance only.
Some of the important terms used in Inheritance -> sub class , super class or child class, parent class.