What are the four pillars of object-oriented programming?
A basic CS interview question asked in fresher, Java, Python, and backend interviews.
0
Asked by KASA community7 Jul 20261 view
KASA answer
The four pillars of object-oriented programming are encapsulation, abstraction, inheritance, and polymorphism. Encapsulation means keeping data and methods together and controlling access. Abstraction means showing only essential details and hiding unnecessary complexity. Inheritance allows one class to reuse or extend another class. Polymorphism allows the same interface or method name to behave differently depending on the object or implementation.
A strong answer should include a simple example, such as a Payment interface with CardPayment and UPIPayment implementations.
Cover these points
Encapsulation controls access to data.
Abstraction hides implementation details.
Inheritance reuses and extends behavior.
Polymorphism allows different implementations through a common interface.