Question: You are given the following code: class Address: This is an Addresss def __init__(self, name= ,number=0): self.__stname=name self.__stnumber=number def setstname(self,name): self.__stname = name def
You are given the following code:
class Address: """This is an Addresss""" def __init__(self, name= " ",number="0"): self.__stname=name self.__stnumber=number def setstname(self,name): self.__stname = name def getstname(self): return self.__stname def setstnumber(self, number): self.__stnumber=number def getstnumber(self): return self.__stnumber def __del__(self): class_name = self.__class__.__name__ print(class_name, "destroyed") ad1=Address() print(ad1.getstname())
del ad1 Which of the following statements is correct?
The output of the program has an error because the ad1 is not defined in print(ad1.getstname()) | ||
The output of the program has an error because the ad1 is not defined in ad1=Address(), there are no values. | ||
The output of the program has an error because the ad1 is not defined in del ad1 and the object can not be destroyed at the end of the program execution | ||
The output of the program is Address destroyed and has no error |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
