What will be the output of the following Python code?
class A:
def __str__(self):
return '1'
class B(A):
def __init__(self):
super().__init__()
class C(B):
def __init__(self):
super().__init__()
def main():
obj1 = B()
obj2 = A()
obj3 = C()
print(obj1, obj2,obj3)
main()
class A:
def __str__(self):
return '1'
class B(A):
def __init__(self):
super().__init__()
class C(B):
def __init__(self):
super().__init__()
def main():
obj1 = B()
obj2 = A()
obj3 = C()
print(obj1, obj2,obj3)
main()A. 1 1 1
B. 1 2 3
C. '1' '1' '1'
D. An exception is thrown
Answer: Option A
Related Questions on Concept of Object Oriented Programs in Python
What is the main goal of object-oriented programming (OOP)?
A. To model real-world entities and their interactions
B. To maximize efficiency
C. To use fewer lines of code
D. To create simple programs
What is an object in the context of object-oriented programming?
A. A specific data type
B. A built-in function
C. An instance of a class
D. A variable in Python
What is a class in the context of object-oriented programming?
A. A blueprint for creating objects
B. A built-in function
C. A variable in Python
D. A specific data type
A. Polymorphism
B. Abstraction
C. Inheritance
D. Encapsulation

Join The Discussion