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()

Question:
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()

1. The program has an error because constructor can’t have default arguments

2.Nothing is displayed

3. “Hello World” is displayed

4.The program has an error display function doesn’t have parameters

Posted Date:-2022-01-02 11:42:58


More MCQS Questions and answers

Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!