Vidyalelo
Python · Q66

Classes and Objects in Python

Programming · Python · question 66

Q66

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

A.
The program has an error because constructor can't have default arguments
B.
Nothing is displayed
C.
"Hello World" is displayed
Answer
D.
The program has an error display function doesn't have parameters

Answer: Option C

Solution

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