Questions tagged [oop]

Object-oriented programming is a programming paradigm using "objects": an encapsulation consisting of data fields and methods together with their interactions.


Object-oriented programming (OOP) is a programming paradigm using the concept of objects. These encapsulates data which is organized in the form of fields (often known as attributes) and code, in the form of procedures (often known as methods). Methods can access and often modify attributes of the object with which they are associated. In OOP, computer programs are designed based on having objects interacting among each other.

OOP includes features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP.


  1. Interface vs Base class
  2. Prefer composition over inheritance?
  3. Polymorphism vs Overriding vs Overloading
  4. What is a class in PHP?
  5. What's the point of OOP?
  6. Inheritance vs. Aggregation
  7. Object-orientation in C
  8. What are the differences between struct and class in C++?
  9. Interface vs Abstract Class (general OO)
  10. What's the difference between a method and a function?
  11. What is the difference between an interface and abstract class?
  12. What is the difference between an abstract function and a virtual function?
  13. What is the difference between public, private, and protected?
  14. Functional programming vs Object Oriented programming
  15. Difference between abstraction and encapsulation?
  16. How do you design object oriented projects?
  17. Difference Between Cohesion and Coupling
  18. prototype based vs. class based inheritance
  19. Aspect Oriented Programming vs. Object-Oriented Programming
  20. What is polymorphism, what is it for, and how is it used?
61861 questions
25 answers

What are metaclasses in Python?

What are metaclasses? What are they used for?
Bite code
  • 578,959
  • 113
  • 301
  • 329
36 answers

@staticmethod vs @classmethod in Python

What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
7 answers

Understanding Python super() with __init__() methods

Why is super() used? Is there a difference between using Base.__init__ and super().__init__? class Base(object): def __init__(self): print "Base created" class ChildA(Base): def __init__(self): Base.__init__(self) …
  • 51,151
  • 22
  • 97
  • 138
39 answers

What is Inversion of Control?

Inversion of Control (IoC) can be quite confusing when it is first encountered. What is it? Which problem does it solve? When is it appropriate to use and when not?
24 answers

When should I use 'self' over '$this'?

In PHP 5, what is the difference between using self and $this? When is each appropriate?
Casey Watson
  • 51,574
  • 10
  • 32
  • 30
42 answers

What's the difference between a method and a function?

Can someone provide a simple explanation of methods vs. functions in OOP context?
  • 38,991
  • 25
  • 88
  • 99
38 answers

What is the difference between an interface and abstract class?

What exactly is the difference between an interface and an abstract class?
  • 377,238
  • 77
  • 533
  • 578
35 answers

Prefer composition over inheritance?

Why prefer composition instead of inheritance? What trade-offs are there for each approach? And the converse question: when should I choose inheritance instead of composition?
  • 343,444
  • 107
  • 203
  • 205
12 answers

Meaning of @classmethod and @staticmethod for beginner

What do @classmethod and @staticmethod mean in Python, and how are they different? When should I use them, why should I use them, and how should I use them? As far as I understand, @classmethod tells a class that it's a method which should be…
37 answers

Why use getters and setters/accessors?

What's the advantage of using getters and setters - that only get and set - instead of simply using public fields for those variables? If getters and setters are ever doing more than just the simple get/set, I can figure this one out very quickly,…
Dean J
  • 39,360
  • 16
  • 67
  • 93
18 answers

What is the meaning of single and double underscore before an object name?

What do single and double leading underscores before an object's name represent in Python?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
27 answers

What is the difference between an abstract method and a virtual method?

What is the difference between an abstract method and a virtual method? In which cases is it recommended to use abstract or virtual methods? Which one is the best approach?
Moran Helman
  • 18,432
  • 4
  • 23
  • 26
28 answers

Why not inherit from List?

When planning out my programs, I often start with a chain of thought like so: A football team is just a list of football players. Therefore, I should represent it with: var football_team = new List(); The ordering of this list…
  • 25,318
  • 14
  • 62
  • 134
6 answers

Why do Python classes inherit object?

Why does the following class declaration inherit from object? class MyClass(object): ...
  • 17,431
  • 6
  • 25
  • 26
34 answers

Interface vs Abstract Class (general OO)

I have recently had two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seems they are waiting for me to mention something…
  • 64,245
  • 87
  • 278
  • 460
2 3
99 100