Vidyalelo
Python · Q44

Classes and Objects in Python

Programming · Python · question 44

Q44

What will be the output of the following Python code? class test: def __init__(self,a): self.a=a def display(self): print(self.a) obj=test() obj.display()

A.
Runs normally, doesn't display anything
B.
Displays 0, which is the automatic default value
C.
Error as one argument is required while creating the object
Answer
D.
Error as display function requires additional argument

Answer: Option C

Solution

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