Which of the following is not an OOP principle?
202520252025
Which of the following is not an OOP principle?
Answer: D. Recursion — Object-Oriented Programming rests on four core principles — Encapsulation (bundling a class's data together with the methods that operate on it and…
- A.
Encapsulation
- B.
Inheritance
- C.
Polymorphism
- D.
Recursion
Show answer & explanation
Correct answer: D
Object-Oriented Programming rests on four core principles — Encapsulation (bundling a class's data together with the methods that operate on it and restricting direct access to that data), Inheritance (a class acquiring and extending the properties and behaviour of a parent class), Polymorphism (a single interface or method behaving differently depending on the actual type of object invoking it), and Abstraction (exposing only essential behaviour while hiding implementation detail). A concept belongs to this list only if it describes how classes or objects relate to each other or organize state and behaviour.
Checking each option against this definition:
Encapsulation — bundles a class's data and methods together and controls access to that data; this is one of the four OOP pillars.
Inheritance — lets one class derive and extend the properties and behaviour of another class; this is one of the four OOP pillars.
Polymorphism — lets a single method or interface behave differently depending on the object's actual type; this is one of the four OOP pillars.
Recursion — a function or procedure calling itself to break a problem into smaller instances of itself; this is a general control-flow technique used in any programming paradigm (procedural, functional, or OOP) and does not describe how classes or objects relate to each other.
Cross-check: recursion can be used inside a method of any class, in purely procedural code, or in a functional language with no classes at all — its presence or absence never changes whether that code is object-oriented, confirming it does not describe a relationship between classes or objects.
So the option that does not describe an OOP principle is recursion.