PRACTICE • LEARN • GROW
Module 8: Object-Oriented Programming - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 8: Object-Oriented Programming - Final Quiz Progress
0 of 12 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What is the purpose of the
self parameter in Python instance methods?
A.
It is a keyword that creates a new class
B.
It is an explicit reference to the specific instance object the method is currently operating on
C.
It is the return value of the constructor
D.
It refers to the parent superclass
Explanation & Key
Correct Answer:
2
What is Python's constructor method called?
A.
__construct__
B.
__init__
C.
__new__
D.
ClassName()
Explanation & Key
Correct Answer:
3
How does a subclass call a method from its parent class in Python?
A.
parent.method()
B.
super().method()
C.
base::method()
D.
this.super.method()
Explanation & Key
Correct Answer:
4
What occurs when an attribute name is prefixed with a double underscore (e.g.
self.__secret = 42)?
A.
It becomes physically inaccessible to the operating system
B.
Python triggers Name Mangling, internally renaming the attribute to _ClassName__secret to avoid accidental overwrites
C.
It becomes a global constant across all classes
D.
It throws a compilation error
Explanation & Key
Correct Answer:
5
What algorithm does Python use to determine the Method Resolution Order (MRO) in multiple inheritance?
A.
Depth-First Search (DFS)
B.
Breadth-First Search (BFS)
C.
C3 Linearization Algorithm
D.
Dijkstra's Algorithm
Explanation & Key
Correct Answer:
6
What design concept is summarized by: 'If it walks like a duck and quacks like a duck, treat it like a duck'?
A.
Static Type Checking
B.
Duck Typing (Dynamic Polymorphism based on method presence rather than inheritance)
C.
Single Inheritance
D.
Data Abstraction
Explanation & Key
Correct Answer:
7
Which dunder method must be implemented on a class to overload the
+ addition operator?
A.
__plus__
B.
__add__
C.
__sum__
D.
__concat__
Explanation & Key
Correct Answer:
8
What is the key difference between
__str__ and __repr__ in Python?
A.
__str__ is for integers; __repr__ is for strings
B.
__str__ provides a readable representation for end users; __repr__ provides an unambiguous, developer-focused representation
C.
__repr__ is deprecated in Python 3
D.
__str__ can only return ASCII characters
Explanation & Key
Correct Answer:
9
What will be the output of the following operator overloading code?
class Vector:
def __init__(self, val):
self.val = val
def __add__(self, other):
return Vector(self.val + other.val)
v1 = Vector(10)
v2 = Vector(25)
v3 = v1 + v2
print(v3.val)
A.
35
B.
Vector(35)
C.
TypeError
D.
10
Explanation & Key
Correct Answer:
10
What is the decorator used to turn a class method into a read-only property (getter)?
A.
@getter
B.
@property
C.
@accessor
D.
@attribute
Explanation & Key
Correct Answer:
11
What first argument does a method decorated with
@classmethod receive by convention?
A.
self (the instance)
B.
cls (the class itself)
C.
None
D.
super
Explanation & Key
Correct Answer:
12
What is a single leading underscore (e.g.
self._balance) in Python OOP?
A.
A strictly enforced private variable
B.
A community convention signaling that the attribute is intended for internal class use only
C.
A syntax error
D.
A static class variable
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong