Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 28)
28.
What will be the output of the following Python code?
class Parent:
def __init__(self, x):
self.x = x
class Child(Parent):
def __init__(self, x, y):
super().__init__(x)
self.y = y
obj = Child(10, 20)
result = obj.x + obj.y
print(result)
Answer: Option
Explanation:
The child class
Child
initializes both x
and y
, and the result is the sum of these attributes.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers