Examveda

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

D. Error as display function requires additional argument

Answer: Option C


This Question Belongs to Python Program >> Classes And Objects In Python

Join The Discussion

Related Questions on Classes and Objects in Python