Q3. Explain the basic concepts of OOP with examples.
Ans. The object oriented programming has been developed with the view to overcome the drawbacks of traditional programming approaches. The OOP approach is based on certain concepts that helps it attain goal of overcoming the drawbacks or shortcomings of traditional programming approaches. These general concepts of OOP are given below:
- Data Abstraction
- Data Encapsulation
- Data Abstraction:
Abstraction is the concept of simplifying a real world concept into its essential elements.
Abstraction refers to the act of representing essential features without including the background details or explanations.
Let’s take the example of ‘switch board’. You only press certain switches according to your requirement. What is happening inside, how it is happening etc. you needn’t know. This is abstraction, you know only the essential things to operate on switch board without knowing the background details of switch board.
Encapsulation is the most fundamental concept of OOP. It is the way of combining both data and the functions that operate on that data under a single unit.