Python OOPs Interview Questions 2026: 30 Q&A With Code

What changed in 2026 drives
Mass-recruiter offer letters are flatter for 2026 batch - the 4-5 LPA ASE band has barely budged in three years while inflation eats real wages. Premium tracks (Digital, Pro, Elite, Specialist) are still where the differential lives, and they are entirely test-driven. If you are aiming higher than the default offer, the coding round is not optional pageantry - it is the entire interview.
What I'd actually study for this
- 01Two solid coding-round answers (1 medium-hard DSA each, with edge-case discussion) > five half-baked ones
- 02One real project you can defend end-to-end - file paths, design decisions, and what you would change
- 03One DBMS schema you actually built (not a textbook ER diagram), with at least 3 join-heavy queries written from memory
- 04Three behavioural STAR stories: failure recovered, conflict handled, ownership taken
Where most candidates trip up
The single biggest mistake is treating company-specific guides as primary prep and DSA as secondary. It is the opposite. Mass recruiters use the test as a filter, but premium tracks at every IT services company use coding to allocate offer band. Spend 70% of prep time on DSA + system fundamentals, 20% on company-specific patterns, 10% on HR rehearsal. Reverse that ratio and you collect the default offer.
Editorial commentary by Aditya Sharma · written for PapersAdda · not generated, not aggregated.
Last Updated: June 2026 | Level: Freshers to Mid-Level | Read Time: ~16 min
Python's object model is a favourite interview area because it differs subtly from Java and C++. Candidates report that self, class versus instance attributes, dunder methods, and the method resolution order are guaranteed topics for Python developer and data-engineering roles. This guide covers 30 Python OOP questions with full answers and runnable code. Behaviour reflects the official Python data-model documentation; confirm any version-specific detail on the official docs.
Pair this with Python Interview Questions 2026 and Python Data Structures Interview Questions 2026.
Table of Contents
- Classes and Instances (Q1 to Q10)
- Inheritance and MRO (Q11 to Q19)
- Dunder and Special Methods (Q20 to Q26)
- Advanced (Q27 to Q30)
- Predict the Output
- Quick Revision Table
- Frequently Asked Questions
Classes and Instances
Q1. What is the role of self in Python? Easy
class Dog:
def __init__(self, name):
self.name = name # self ties data to this instance
def bark(self):
return f"{self.name} says woof"
Q2. What is the difference between a class attribute and an instance attribute? Medium
class Counter:
total = 0 # class attribute, shared
def __init__(self):
self.id = Counter.total
Counter.total += 1
Q3. What is init and is it a constructor? Easy
Q4. What is the difference between new and init? Hard
Q5. What are instance, class, and static methods? Medium
class Pizza:
def __init__(self, size): self.size = size
@classmethod
def large(cls): return cls(16) # alternative constructor
@staticmethod
def area(r): return 3.14 * r * r # utility
Q6. What is encapsulation in Python? Medium
Q7. What is name mangling? Hard
Q8. What are property decorators? Medium
class Account:
def __init__(self): self._balance = 0
@property
def balance(self): return self._balance
@balance.setter
def balance(self, v):
if v >= 0: self._balance = v
Q9. What does slots do? Hard
Q10. What is a dataclass? Medium
from dataclasses import dataclass
@dataclass
class Point:
x: int
y: int
Inheritance and MRO
Q11. How does inheritance work in Python? Easy
class Animal:
def speak(self): return "..."
class Cat(Animal):
def speak(self): return "meow"
Q12. What is super() and why use it? Medium
class Base:
def __init__(self): self.a = 1
class Derived(Base):
def __init__(self):
super().__init__() # run Base setup first
self.b = 2
Q13. What is the method resolution order (MRO)? Hard
Q14. How does Python solve the diamond problem? Hard
Q15. What is the difference between isinstance and issubclass? Easy
Q16. What is duck typing? Medium
Q17. What is an abstract base class? Medium
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self): ...
Q18. What is method overriding and does Python have overloading? Medium
Q19. What is a mixin? Hard
Dunder and Special Methods
Q20. What is the difference between str and repr? Medium
Q21. How do you make a class comparable? Medium
Q22. How do you make an object iterable? Medium
class Range3:
def __iter__(self):
for i in range(3): yield i
Q23. What does call do? Hard
Q24. How do you support len() and indexing? Medium
Q25. What is eq and its link to hash? Hard
Q26. What are context managers and enter/exit? Medium
with open("f.txt") as f: # __enter__/__exit__ handle close
data = f.read()
Advanced
Q27. What is a metaclass? Hard
Q28. What is the difference between composition and inheritance in Python? Medium
Q29. Are everything-is-an-object claims true in Python? Medium
Q30. How does garbage collection work in Python? Hard
Predict the Output
Snippet 1
class A:
items = []
def add(self, x): self.items.append(x)
a, b = A(), A()
a.add(1); b.add(2)
print(a.items)
Output:
[1, 2]
Why: items is a class attribute shared by all instances, so both appends modify the same list. The classic mutable-class-attribute trap. Use self.items = [] in __init__ for per-instance lists.
Snippet 2
class A:
def who(self): return "A"
class B(A):
def who(self): return "B " + super().who()
print(B().who())
Output:
B A
Why: B.who calls super().who() which resolves to A.who via the MRO, concatenating the results.
Snippet 3
print(type(type))
print(isinstance(5, object))
Output:
<class 'type'>
True
Why: type is its own metaclass, and every value including int derives from object, so 5 is an instance of object.
Quick Revision Table
| Concept | Key takeaway |
|---|---|
| self | explicit instance reference |
| class vs instance attr | shared vs per-object |
| init vs new | initialise vs create |
| MRO | C3 linearisation, deterministic |
| super() | delegates to next in MRO |
| str vs repr | readable vs unambiguous |
| eq and hash | define together for hashable |
| mutable class attr | shared, common trap |
Frequently Asked Questions
Which Python OOP topic is asked most in 2026?
Candidates report that the difference between class and instance attributes, the role of self, and the method resolution order for multiple inheritance are the three most repeated Python OOP questions.
Do Python interviews ask about dunder methods?
Yes. __init__, __str__, __repr__, __eq__, and __len__ come up regularly, with interviewers asking you to make a class printable, comparable, or iterable by implementing the right dunder.
Is multiple inheritance asked in Python interviews?
Often, because Python allows it. Interviewers probe the C3 linearisation MRO, the role of super, and the diamond problem, which Python resolves deterministically unlike Java, which bans class multiple inheritance.
Why does a mutable class attribute cause bugs?
Because it is shared across all instances, so appending to a class-level list affects every object. Always initialise mutable per-instance state inside __init__ with self, never as a bare class attribute.
What is the difference between a classmethod and a staticmethod?
A classmethod receives the class as cls and is commonly used for alternative constructors, while a staticmethod receives nothing and is just a function grouped under the class for namespacing.
Related Articles
- Python Interview Questions 2026, the master set
- Python Data Structures Interview Questions 2026, lists, dicts and more
- Python Output Prediction Questions 2026, tricky snippets
- Java OOPs Interview Questions 2026, compare with Java's model
Confirm any version-specific behaviour on the official Python documentation before your interview. This guide reflects candidate-reported patterns and public preparation resources as of June 2026.
Methodology applied to this articlelast verified 8 Jun 2026
- No fabricated salary numbers or success rates. If we quote a range, it's sourced.
- No noun-substituted templates. This article was not generated by swapping company names in a stock prompt.
- No paid placements, sponsored coaching links, or affiliate-shilled course pushes.
Explore this topic cluster
More resources in Interview Questions
Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.
Paid contributor programme
Sat this this year? Share your story, earn ₹500.
First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story - with byline.
Submit your story →Ready to practice?
Take a free timed mock test
Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.
Start Free Mock Test →Related Articles
Airbnb Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing Airbnb's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical, behavioural,...
Airtel Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing Airtel's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical, behavioural,...
AMD Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing AMD's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical, behavioural,...
Atlassian Interview Questions 2026: Top Tech, HR & Behavioural Q&As for Freshers
Clearing Atlassian's fresher loop in 2026 comes down to preparing for the exact mix of questions across technical,...
Barclays Interview Questions 2026
_Last verified by [Aditya Sharma](/author/aditya-sharma/) · cross-checked against PapersAdda Hiring Pulse and...
More from PapersAdda
Accenture Interview Process 2026: Rounds & Prep
Accenture Interview Questions 2026 (with Answers for Freshers)
Adobe Interview Process 2026: Rounds, OA & Aptitude
Amazon Interview Process 2026: Full Loop + Bar Raiser