Vidyalelo
Python · Q51

Classes and Objects in Python

Programming · Python · question 51

Q51

What will be the output of the following Python code? class test: def __init__(self): self.variable = 'Old' self.Change(self.variable) def Change(self, var): var = 'New' obj=test() print(obj.variable)

A.
Error because function change can't be called in the __init__ function
B.
'New' is printed
C.
'Old' is printed
Answer
D.
Nothing is printed

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board