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()
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
D. The program has an error display function doesn't have parameters
Answer: Option C
Join The Discussion