4/20/26, 2:02 PM Python Objective Questions
1. Constructor Behavior
class A:
def __init__(self):
print("Init A")
class B(A):
pass
obj = B()
What is the output?
A) Init B
B) Init A
C) Error
D) Nothing
2. Attribute Access
class A:
def __init__(self):
self.x = 10
obj1 = A()
obj2 = A()
obj1.x = 20
print(obj2.x)
A) 10
B) 20
C) Error
D) None
3. Class vs Instance Variable
class A:
x = 5
[Link] 1/9
4/20/26, 2:02 PM Python Objective Questions
obj1 = A()
obj2 = A()
obj1.x = 10
print(obj2.x)
A) 5
B) 10
C) Error
D) None
4. Debug the Error
class A:
def __init__(self, x):
self.x = x
obj = A()
What happens?
A) Works fine
B) TypeError
C) AttributeError
D) SyntaxError
5. Method Call Issue
class A:
def show():
print("Hello")
obj = A()
[Link]()
A) Hello
B) Error
[Link] 2/9
4/20/26, 2:02 PM Python Objective Questions
C) None
D) 0
6. Private Variable Access
class A:
def __init__(self):
self.__x = 5
obj = A()
print(obj._A__x)
A) 5
B) Error
C) None
D) 0
7. Inheritance Chain
class A:
def show(self):
print("A")
class B(A):
pass
class C(B):
pass
obj = C()
[Link]()
A) A
B) B
C) C
D) Error
[Link] 3/9
4/20/26, 2:02 PM Python Objective Questions
8. Method Overriding with super()
class A:
def show(self):
print("A")
class B(A):
def show(self):
super().show()
print("B")
obj = B()
[Link]()
A) B
B) A B
C) A
D) Error
9. Operator Overloading Case
class A:
def __add__(self, other):
return 10
obj1 = A()
obj2 = A()
print(obj1 + obj2)
A) Error
B) 10
C) obj
D) None
10. Abstract Class Error
from abc import ABC, abstractmethod
[Link] 4/9
4/20/26, 2:02 PM Python Objective Questions
class A(ABC):
@abstractmethod
def show(self):
pass
obj = A()
A) Works
B) TypeError
C) SyntaxError
D) None
11. MRO Case
class A:
def show(self):
print("A")
class B(A):
def show(self):
print("B")
class C(A):
def show(self):
print("C")
class D(B, C):
pass
obj = D()
[Link]()
A) A
B) B
C) C
D) Error
[Link] 5/9
4/20/26, 2:02 PM Python Objective Questions
12. Exception Flow
try:
print("Try")
except:
print("Except")
else:
print("Else")
finally:
print("Finally")
A) Try Else Finally
B) Try Finally
C) Try Except Finally
D) Error
13. finally Block Behavior
try:
return_value = 1
finally:
return_value = 2
print(return_value)
A) 1
B) 2
C) Error
D) None
14. str Debugging
class A:
def __str__(self):
return 5
obj = A()
print(obj)
[Link] 6/9
4/20/26, 2:02 PM Python Objective Questions
A) 5
B) Error
C) None
D) A
15. Multiple Constructors
class A:
def __init__(self, x=0):
self.x = x
obj = A()
print(obj.x)
A) 0
B) Error
C) None
D) 1
16. Mutable Default Trap
class A:
def __init__(self, x=[]):
self.x = x
obj1 = A()
obj2 = A()
[Link](1)
print(obj2.x)
A) []
B) [1]
C) Error
D) None
[Link] 7/9
4/20/26, 2:02 PM Python Objective Questions
17. Method Missing self
class A:
def show(self):
print("Hello")
[Link]()
A) Hello
B) Error
C) None
D) 0
18. len Case
class A:
def __len__(self):
return "5"
obj = A()
print(len(obj))
A) 5
B) Error
C) "5"
D) None
19. Dynamic Attribute
class A:
pass
obj = A()
obj.x = 10
print(obj.x)
[Link] 8/9
4/20/26, 2:02 PM Python Objective Questions
A) 10
B) Error
C) None
D) 0
20. Deletion Case
class A:
def __del__(self):
print("Deleted")
obj = A()
del obj
A) Deleted
B) Error
C) Nothing
D) None
[Link] 9/9