What is OCP in object-oriented programming?
The Open-Closed Principle (OCP) states that software entities (classes, modules, methods, etc.) should be open for extension, but closed for modification. In practice, this means creating software entities whose behavior can be changed without the need to edit and recompile the code itself.
What are the 4 pillars of object-oriented design?
The four pillars for OOP are Abstraction, Encapsulation, Inheritance, Polymorphism. Abstraction : Abstraction is the process of showing only essential/necessary features of an entity/object to the outside world and hide the other irrelevant information.

What are two strategies to implement OCP?
These five principles are:
- The Single Responsibility Principle: A class should have one, and only one, reason to change.
- The Open Closed Principle: Software entities should be open to extension but closed to modification.
- The Liskov Substitution Principle: Derived classes must be substitutable for their base classes.
Is Liskov Substitution polymorphism?
The Liskov Substitution Principle (LSP) is strongly related to subtyping polymorphism. Based on subtyping polymorphism in an object-oriented language, a derived object can be substituted with its parent type. For example, if we have a Car object, it can be used in the code as a Vehicle .
What are the 5 concepts of OOPS?

An Introduction to OOPS Concepts in Java | Abstraction Inheritance Polymorphism
- Objects & Classes. Objects are the basic unit of OOPS representing real-life entities.
- Abstraction.
- Encapsulation.
- Inheritance – Single, Multilevel, Hierarchical, and Multiple.
- Polymorphism – Static and Dynamic.
What are 4 OOP principles in Java?
Abstraction, encapsulation, polymorphism, and inheritance are the four main theoretical principles of object-oriented programming. But Java also works with three further OOP concepts: association, aggregation, and composition.
How many pillars are there in OOP?
To be truly practicing object-oriented programming, you must be using all three of the “pillars”, i.e., encapsulation, inheritance, and polymorphism.