🚀 Supercharge your YouTube channel's growth with AI.
Try YTGrowAI FreeTop 100 Python OOP MCQs for Coding Exams (2026)

OOPs (Object-Oriented Programming) means writing code using objects and classes. There are four pillars of OOP: inheritance (reusing properties of a parent class), polymorphism (one interface, multiple behaviours), encapsulation (hiding data inside classes), and abstraction (showing only essential details).
Python Object-Oriented Programming helps us write clean, reusable, and scalable code using these pillars. In this article, I have compiled 100 Python OOP MCQs to help you practice different concepts related to OOP and prepare for interviews and coding exams in 2026.
100 Python OOP MCQs with Answers
Go through each Python OOP MCQ one by one and try to answer it based on your own knowledge. If you get stuck anywhere, remember we are in the AI era, just copy the MCQ and ask an AI tool to “explain the concept behind this question.” This way, you will understand the logic and remember it more easily.
Q1. Which keyword is used to define a new class in Python?
A. class
B. def
C. struct
D. object
Show Answer
Answer: A
The class keyword is used to create a blueprint for objects in Python.
Q2. What is the correct syntax to create an object of a class named “Student”?
A. Student obj = new Student();
B. obj = Student();
C. obj = new Student();
D. create obj = Student();
Show Answer
Answer: B
In Python, objects are created by calling the class name followed by parentheses.
Q3. Which method is automatically called when a new object is created?
A. __new__
B. __init__
C. __create__
D. __start__
Show Answer
Answer: B
The __init__ method acts as a constructor to initialize the object’s attributes.
Q4. What does the ‘self’ keyword represent in a Python class method?
A. The parent class
B. The current instance of the class
C. A static variable
D. A global variable
Show Answer
Answer: Bself refers to the specific object instance calling the method.
Q5. Which of the following is a correct convention for naming a private attribute in a Python class?
A. __name
B. name__
C. _name
D. Name
Show Answer
Answer: A
Prefixing an attribute with double underscores __ invokes name mangling to make it private.
Q6. Which type of inheritance occurs when a child class inherits from multiple parent classes?
A. Single Inheritance
B. Multilevel Inheritance
C. Multiple Inheritance
D. Hierarchical Inheritance
Show Answer
Answer: C
Multiple inheritance allows a class to derive features from more than one base class.
Q7. What is the output of the following code?
class Test:
def __init__(self):
self.x = 1
t = Test()
print(t.x)
Show Answer
Answer: 1
The attribute x is initialized to 1 in the constructor and accessed via the object.
Q8. Which method is used to access the parent class method from a child class in Python?
A. this.method()
B. super().method()
C. parent.method()
D. base.method()
Show Answer
Answer: B
The super() function returns a proxy object that allows access to methods of the parent class.
Q9. What is polymorphism in the context of Python OOPs?
A. Hiding data implementation
B. Ability to take various forms
C. Creating new classes
D. Binding data and functions
Show Answer
Answer: B
Polymorphism allows methods to do different things based on the object it is acting upon.
Q10. Which decorator is used to define a static method inside a class?
A. @staticmethod
B. @static
C. @classstaticmethod
D. @staticmethoddef
Show Answer
Answer: A
The @staticmethod decorator defines a method that does not receive an implicit first argument.
Q11. What does encapsulation refer to in Python?
A. Creating multiple objects
B. Bundling data and methods that work on the data
C. Inheriting properties
D. Overloading operators
Show Answer
Answer: B
Encapsulation is the concept of wrapping data (variables) and code (methods) together as a single unit.
Q12. Which function is used to check if an object is an instance of a particular class?
A. checkinstance()
B. isinstance()
C. typeof()
D. instance()
Show Answer
Answer: B
The isinstance() function returns True if the object belongs to the specified class.
Q13. What is the result of Method Resolution Order (MRO) in Python?
A. Order in which methods are deleted
B. Order in which base classes are searched for a method
C. Order in which objects are created
D. Order in which variables are assigned
Show Answer
Answer: B
MRO defines the order in which the interpreter looks for a method in a hierarchy of classes.
Q14. How do you define a class method in Python?
A. Using @classmethod decorator and cls parameter
B. Using @class decorator
C. Using self parameter
D. Using static keyword
Show Answer
Answer: A
Class methods take cls as the first parameter and are marked with the @classmethod decorator.
Q15. Which special method is used to overload the ‘+’ operator for a custom class?
A. __add__
B. __sum__
C. __plus__
D. __increment__
Show Answer
Answer: A
The __add__ magic method enables the use of the + operator for objects of the class.
Q16. What is abstraction in Python OOPs?
A. Hiding complex implementation details
B. Creating multiple instances
C. Copying objects
D. Deleting objects
Show Answer
Answer: A
Abstraction involves hiding the complex reality while exposing only the necessary parts.
Q17. Which module is used to create Abstract Base Classes (ABCs) in Python?
A. abc
B. abstract
C. interface
D. abc_module
Show Answer
Answer: A
The abc module provides the infrastructure for defining abstract base classes.
Q18. What is the purpose of the __str__ method in a class?
A. To convert an object to a string representation
B. To delete the object
C. To initialize the object
D. To compare two objects
Show Answer
Answer: A
The __str__ method returns a string version of the object, used by the print() function.
Q19. What does the __del__ method do?
A. Initializes an object
B. Deletes an object from memory
C. Creates a copy of an object
D. Compares two objects
Show Answer
Answer: B
The __del__ method is a destructor called when an object is about to be destroyed.
Q20. Which of the following allows different classes to use the same method name?
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Instantiation
Show Answer
Answer: B
Polymorphism allows different classes to define methods with the same name.
Q21. Which OOPs concept restricts direct access to an object’s data?
A. Inheritance
B. Data Hiding
C. Polymorphism
D. Instantiation
Show Answer
Answer: B
Data hiding restricts access to certain details, often implemented using private members.
Q22. A child class inherits from a parent class. What is this relationship called?
A. Has-A relationship
B. Is-A relationship
C. Uses-A relationship
D. Part-of relationship
Show Answer
Answer: B
Inheritance implies an “Is-A” relationship between the child and parent classes.
Q23. Which function can determine if a class is a subclass of another class?
A. isinstance()
B. issubclass()
C. ischild()
D. checkinheritance()
Show Answer
Answer: B
The issubclass() function checks if a class is derived from another class.
Q24. What happens if a method in a child class has the same name as a method in the parent class?
A. Error occurs
B. Parent method is called
C. Child method overrides the parent method
D. Both methods run simultaneously
Show Answer
Answer: C
This concept is known as Method Overriding, where the child implementation replaces the parent’s.
Q25. Which concept allows a class to act as a blueprint for other classes without being fully implemented?
A. Concrete Class
B. Abstract Class
C. Static Class
D. Final Class
Show Answer
Answer: B
An abstract class cannot be instantiated and often contains abstract methods to be defined by subclasses.
Q26. Can a Python class have multiple __init__ methods?
A. Yes
B. No
C. Only if inherited
D. Only with decorators
Show Answer
Answer: B
Python does not support constructor overloading; the last defined __init__ method overwrites previous ones.
Q27. What is the primary use of the @property decorator?
A. To define static variables
B. To define getters, setters, and deleters
C. To create class constants
D. To speed up execution
Show Answer
Answer: B
The @property decorator allows method access like an attribute, commonly used for encapsulation.
Q28. In Python, is operator overloading supported?
A. No
B. Yes
C. Only for + and –
D. Only for built-in types
Show Answer
Answer: B
Python supports operator overloading via special “magic” or “dunder” methods.
Q29. Which method is called when print(obj) is executed for an object without __str__?
A. __repr__
B. __print__
C. __output__
D. __display__
Show Answer
Answer: A
If __str__ is not found, Python falls back to the __repr__ method.
Q30. What is the behavior of protected members in Python?
A. They cannot be accessed outside the class
B. They can be accessed only inside the class and its subclasses
C. They are accessible publicly but indicated by a single underscore
D. They are completely hidden
Show Answer
Answer: C
Protected members (prefixed with _) are a convention; they are technically accessible but meant for internal use.
Q31. Which inheritance type involves a class inheriting from a derived class?
A. Single Inheritance
B. Multilevel Inheritance
C. Multiple Inheritance
D. Hybrid Inheritance
Show Answer
Answer: B
Multilevel inheritance forms a chain where a class inherits from a child class.
Q32. What is the default return value of __init__?
A. The object instance
B. None
C. True
D. 0
Show Answer
Answer: B
The __init__ method should not return any value; it returns None implicitly.
Q33. How does Python achieve data hiding?
A. Using private variables
B. Using global variables
C. Using lists
D. Using loops
Show Answer
Answer: A
Private variables, denoted by double underscores, are used to restrict direct access.
Q34. Which method is used to return the length of an object?
A. __len__
B. __length__
C. __size__
D. __count__
Show Answer
Answer: A
The __len__ method allows the use of the len() function on custom objects.
Q35. What is the difference between a class variable and an instance variable?
A. Class variables are shared, instance variables are unique to each object
B. Class variables are private, instance variables are public
C. No difference
D. Class variables are faster
Show Answer
Answer: A
Class variables are defined outside methods and shared by all instances, while instance variables are unique.
Q36. What is a constructor in Python?
A. A method to destroy objects
B. A special method to initialize objects
C. A variable to store data
D. A loop inside a class
Show Answer
Answer: B
A constructor (typically __init__) initializes the state of an object when it is created.
Q37. Which OOP principle allows a class to use methods of another class without inheritance?
A. Composition
B. Encapsulation
C. Abstraction
D. Polymorphism
Show Answer
Answer: A
Composition is a “Has-A” relationship where a class contains an object of another class.
Q38. What is the use of the pass statement in a class definition?
A. To create an empty class
B. To delete the class
C. To initialize variables
D. To return a value
Show Answer
Answer: A
The pass statement acts as a placeholder for an empty class body.
Q39. What will happen if you try to create an object of an abstract class?
A. Object is created successfully
B. Python raises an error
C. Object is created without methods
D. Nothing happens
Show Answer
Answer: B
Python raises a TypeError if you try to instantiate an abstract class directly.
Q40. Which method is called when an object is indexed like a list (obj[key])?
A. __index__
B. __getitem__
C. __key__
D. __access__
Show Answer
Answer: B
The __getitem__ method allows objects to support indexing operations.
Q41. What is duck typing in Python?
A. Strict type checking
B. Determining object type by its behavior
C. A type of inheritance
D. Creating duck objects
Show Answer
Answer: B
Duck typing means the object type is determined by the methods it has, not its class inheritance.
Q42. Which method overloads the function call operation ()?
A. __call__
B. __invoke__
C. __run__
D. __execute__
Show Answer
Answer: A
The __call__ method allows an object to be called like a function.
Q43. How do you define a destructor in Python?
A. __destroy__ method
B. __del__ method
C. __remove__ method
D. __end__ method
Show Answer
Answer: B
The __del__ method is called when the garbage collector is about to destroy the object.
Q44. What is name mangling in Python?
A. Changing method names
B. Modifying private variable names to avoid conflicts
C. Renaming classes
D. Deleting object names
Show Answer
Answer: B
Name mangling rewrites private attribute names (e.g., __var to _ClassName__var) to prevent collisions.
Q45. Which method is used to compare two objects using ==?
A. __cmp__
B. __eq__
C. __equal__
D. __check__
Show Answer
Answer: B
The __eq__ method is overridden to define custom equality logic for objects.
Q46. Which of the following is NOT a type of inheritance in Python?
A. Single
B. Double
C. Multiple
D. Multilevel
Show Answer
Answer: B
Python supports Single, Multiple, Multilevel, Hierarchical, and Hybrid inheritance, but not “Double”.
Q47. What is the output of len(obj) if __len__ returns “five”?
A. five
B. 5
C. TypeError
D. None
Show Answer
Answer: C
The __len__ method must return a non-negative integer; otherwise, a TypeError is raised.
Q48. Which concept is implemented using the super() function?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Abstraction
Show Answer
Answer: Bsuper() is primarily used to call methods of the parent class to facilitate inheritance.
Q49. Can a static method access instance variables?
A. Yes
B. No
C. Only if public
D. Only if global
Show Answer
Answer: B
Static methods do not receive the instance (self) argument, so they cannot access instance variables.
Q50. Which decorator is used to define an abstract method?
A. @abstractmethod
B. @abstract
C. @base
D. @interface
Show Answer
Answer: A
The @abstractmethod decorator from the abc module declares a method that must be implemented by subclasses.
Q51. What is a “Has-A” relationship in Python?
A. Inheritance
B. Aggregation/Composition
C. Polymorphism
D. Instantiation
Show Answer
Answer: B
A “Has-A” relationship implies that one class contains an object of another class (Composition).
Q52. What is the use of the __dict__ attribute?
A. Stores class methods
B. Stores the namespace of the object/class
C. Stores inheritance hierarchy
D. Stores built-in functions
Show Answer
Answer: B
The __dict__ attribute is a dictionary containing the object’s or class’s writable attributes.
Q53. Which method handles attribute access (obj.attr)?
A. __getattr__
B. __setattr__
C. __getattribute__
D. Both A and C
Show Answer
Answer: D__getattribute__ is called for every access, while __getattr__ is called only when the attribute is missing.
Q54. Which function returns the class of an object?
A. type()
B. class()
C. typeof()
D. getclass()
Show Answer
Answer: A
The type() function returns the type or class of the object passed to it.
Q55. What is method overloading?
A. Defining multiple methods with the same name but different parameters
B. Redefining a parent method
C. Deleting a method
D. Creating static methods
Show Answer
Answer: A
Method overloading allows defining methods with the same name but different argument lists (not natively supported in Python).
Q56. Does Python support method overloading by default?
A. Yes, natively
B. No, but it can be simulated
C. Yes, only for constructors
D. No, never
Show Answer
Answer: B
Python does not support traditional overloading but can simulate it using default arguments or variable arguments.
Q57. Which keyword is required to inherit a class in Python?
A. inherits
B. extends
C. (Parentheses with parent class name)
D. super
Show Answer
Answer: C
In Python, inheritance is done by passing the parent class name in parentheses during definition.
Q58. What is the role of the __new__ method?
A. To initialize the object
B. To create the object instance
C. To delete the object
D. To call the parent class
Show Answer
Answer: B__new__ is responsible for creating the instance before __init__ initializes it.
Q59. Which exception is raised if an abstract method is not implemented?
A. AttributeError
B. NotImplementedError
C. TypeError
D. ValueError
Show Answer
Answer: C
Python raises a TypeError if you try to instantiate a class without implementing its abstract methods.
Q60. What is the output of the following code?
class A:
pass
class B(A):
pass
print(issubclass(B, A))
Show Answer
Answer: True
B is explicitly derived from A, so issubclass(B, A) returns True.
Q61. How can you access a private member __x of class A outside the class?
A. obj.__x
B. obj._A__x
C. obj.private.x
D. Cannot be accessed
Show Answer
Answer: B
Private members can be accessed using name mangling syntax: _ClassName__attribute.
Q62. Which OOP concept binds data and code together?
A. Inheritance
B. Encapsulation
C. Abstraction
D. Polymorphism
Show Answer
Answer: B
Encapsulation binds the data (variables) and the code (methods) acting on the data within a single unit.
Q63. What is an instance in Python?
A. A blueprint
B. An object created from a class
C. A method
D. A variable
Show Answer
Answer: B
An instance is a specific object created from a particular class.
Q64. Which method overloads the multiplication operator *?
A. __mul__
B. __multiply__
C. __prod__
D. __times__
Show Answer
Answer: A
The __mul__ method allows custom implementation for the * operator.
Q65. What is the difference between class methods and static methods?
A. Class methods take cls, static methods take no specific first argument
B. Static methods take cls, class methods take self
C. No difference
D. Static methods can access instance variables
Show Answer
Answer: A
Class methods receive the class (cls) as the first argument, while static methods receive neither instance nor class.
Q66. Which method allows an object to be iterated over in a loop?
A. __iter__
B. __next__
C. Both A and B
D. __loop__
Show Answer
Answer: C
Iterators require both __iter__ and __next__ methods to function in a loop.
Q67. What does the __bases__ attribute contain?
A. List of derived classes
B. Tuple of base classes
C. List of class methods
D. Dictionary of attributes
Show Answer
Answer: B
The __bases__ attribute holds a tuple of the class’s direct parent classes.
Q68. Which function is used to modify the MRO of a class?
A. mro()
B. Cannot be modified manually
C. setmro()
D. order()
Show Answer
Answer: B
MRO is calculated automatically by Python’s C3 algorithm and cannot be manually modified.
Q69. What is a concrete class?
A. A class with only abstract methods
B. A class that can be instantiated
C. A class with no methods
D. A static class
Show Answer
Answer: B
A concrete class is a fully implemented class that can be instantiated.
Q70. How is hierarchical inheritance defined?
A. One parent, multiple children
B. Multiple parents, one child
C. One parent, one child
D. Chain of inheritance
Show Answer
Answer: A
Hierarchical inheritance occurs when one base class is inherited by multiple derived classes.
Q71. What happens if you call a method without self in a class definition?
A. It works as a static method
B. It raises a TypeError
C. It works as a class method
D. It is ignored
Show Answer
Answer: A
If called via the class name, it works like a static function, but calling via instance fails.
Q72. Which method is used to set an attribute value?
A. __getattribute__
B. __setattr__
C. __delattr__
D. __access__
Show Answer
Answer: B
The __setattr__ method is invoked when an attribute assignment is attempted.
Q73. What is a metaclass in Python?
A. A class of a class
B. A method inside a class
C. An instance of a class
D. A deleted class
Show Answer
Answer: A
A metaclass is a class whose instances are classes; it defines how classes behave.
Q74. Which function returns the Method Resolution Order?
A. mro()
B. order()
C. hierarchy()
D. resolution()
Show Answer
Answer: A
The mro() method or the __mro__ attribute returns the method resolution order.
Q75. What is the default metaclass in Python?
A. object
B. type
C. class
D. instance
Show Answer
Answer: B
The type class is the default metaclass for all classes in Python.
Q76. Which magic method implements the ‘with’ statement?
A. __enter__ and __exit__
B. __with__ and __end__
C. __start__ and __stop__
D. __init__ and __del__
Show Answer
Answer: A
Context managers use __enter__ (setup) and __exit__ (teardown) methods.
Q77. Which statement is true about shallow copy?
A. Creates a copy of nested objects
B. Creates a new object but references nested objects
C. Does not create a new object
D. Copies all data recursively
Show Answer
Answer: B
Shallow copy creates a new container but fills it with references to the original child objects.
Q78. What is deepcopy in Python?
A. Copying only the top-level object
B. Copying the object and all objects referenced by it
C. Copying the reference
D. Deleting the original object
Show Answer
Answer: B
Deepcopy creates a fully independent copy of the object and all nested structures.
Q79. Which method is used to define a custom iterator?
A. __iter__() and __next__()
B. __start__() and __end__()
C. __begin__() and __finish__()
D. __init__() and __del__()
Show Answer
Answer: A
Implementing __iter__ and __next__ makes an object iterable.
Q80. What is the use of the __slots__ attribute?
A. To restrict dynamic attribute creation and save memory
B. To create slots for methods
C. To define class variables
D. To increase execution speed
Show Answer
Answer: A__slots__ prevents the creation of __dict__ and restricts valid attribute names.
Q81. Can you inherit from multiple built-in types like list or dict?
A. No
B. Yes
C. Only from list
D. Only from dict
Show Answer
Answer: B
Python allows inheriting from built-in types to extend their functionality.
Q82. What is the diamond problem in inheritance?
A. An ambiguity arising in multiple inheritance
B. A syntax error
C. A runtime exception
D. A logic error in loops
Show Answer
Answer: A
It occurs when a class inherits from two classes that both inherit from a single base class, creating ambiguity.
Q83. How does Python resolve the diamond problem?
A. Compilation error
B. Using MRO (Method Resolution Order)
C. Random selection
D. Cannot be resolved
Show Answer
Answer: B
Python uses C3 linearization (MRO) to determine the order in which base classes are searched.
Q84. What is the __hash__ method used for?
A. To encrypt object data
B. To return an integer used for dictionary keys
C. To compare objects
D. To delete objects
Show Answer
Answer: B
The __hash__ method returns an integer hash value, enabling objects to be used as dictionary keys.
Q85. If a class defines __eq__ but not __hash__, what happens?
A. It is hashable
B. It becomes unhashable
C. It causes a syntax error
D. It inherits parent hash
Show Answer
Answer: B
If you define __eq__, Python automatically sets __hash__ to None, making the object unhashable.
Q86. Which method is called when ‘len(obj)’ is executed?
A. __len__
B. __length__
C. __sizeof__
D. __size__
Show Answer
Answer: A
The built-in len() function invokes the __len__ method of the object.
Q87. Which method is used for string representation for developers (debugging)?
A. __str__
B. __repr__
C. __debug__
D. __format__
Show Answer
Answer: B__repr__ is intended to produce an unambiguous string representation, useful for debugging.
Q88. Which OOP concept allows the same function name to work for different types?
A. Inheritance
B. Polymorphism
C. Encapsulation
D. Instantiation
Show Answer
Answer: B
Polymorphism allows functions to operate on different data types or classes.
Q89. What is the first argument of a class method?
A. self
B. cls
C. this
D. object
Show Answer
Answer: B
Class methods accept cls as the first argument, representing the class itself.
Q90. Can a class method modify the class state?
A. Yes
B. No
C. Only static state
D. Only instance state
Show Answer
Answer: A
Class methods can modify class variables that apply to all instances.
Q91. What is the purpose of the __bool__ method?
A. To convert object to boolean
B. To check if object exists
C. To compare objects
D. To delete objects
Show Answer
Answer: A
The __bool__ method defines the truth value of an object.
Q92. Which method handles the ‘in’ keyword operator?
A. __in__
B. __contains__
C. __has__
D. __member__
Show Answer
Answer: B
The __contains__ method allows an object to respond to membership tests using in.
Q93. What happens if you print an object without __str__ or __repr__?
A. Output is empty
B. Output is the object’s memory address
C. Python raises an error
D. Output is “None”
Show Answer
Answer: B
Python prints the default representation: class name and memory address (e.g., <__main__.MyClass object at 0x...>).
Q94. Which term describes defining a method in a child class that already exists in the parent class?
A. Overloading
B. Overriding
C. Inheritance
D. Polymorphism
Show Answer
Answer: B
Method overriding allows a subclass to provide a specific implementation of a method defined in the parent.
Q95. What is the default base class for all classes in Python 3?
A. main
B. object
C. class
D. type
Show Answer
Answer: B
All classes in Python 3 implicitly inherit from the object class.
Q96. Which function is used to create a class dynamically?
A. create()
B. type()
C. class()
D. new()
Show Answer
Answer: B
The type() function can be used as a metaclass to create classes dynamically.
Q97. What is the __init_subclass__ method used for?
A. To initialize the subclass
B. To customize behavior when a class is subclassed
C. To delete a subclass
D. To copy a class
Show Answer
Answer: B
This hook is called whenever the containing class is subclassed.
Q98. Which method is called when an object is used as a context manager?
A. __context__
B. __enter__
C. __init__
D. __main__
Show Answer
Answer: B
The __enter__ method is called when entering the with block.
Q99. Which of the following is true about a protected member?
A. Accessible only within the class
B. Accessible within the class and its subclasses
C. Cannot be accessed at all
D. Accessible globally
Show Answer
Answer: B
Protected members (single underscore) are accessible to the class and its subclasses by convention.
Q100. What is Hybrid Inheritance?
A. A combination of two or more types of inheritance
B. Inheritance from a single base class
C. Inheritance from no base class
D. A type of multiple inheritance
Show Answer
Answer: A
Hybrid inheritance is a mix of different inheritance types, such as multiple and hierarchical.
Conclusion
If you made it here, you’ve already done more than most learners. These 100 Python OOP MCQs aren’t just for exams, but they help you learn key concepts, unlike traditional ways, by letting you do problem-solving.
If you want to strengthen your OOP fundamentals, you can start with this detailed guide on Object-Oriented Programming in Python, which explains classes, objects, and core concepts. You can also explore Python Classes and Objects to understand how OOP works in real code, along with tutorials on constructors and inheritance available in the Python OOP section.
At last, make sure to bookmark this page for later revision. Just press Ctrl + D on Windows or Cmd + D on Mac so you can easily revisit these Python OOP MCQs anytime you need.

