B01A-2015 – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12A-2015-B01A #PYTHON#6334    siteicon   siteicon  

Problem Statement - B01A-2015

How is __init( ) __different from __del ( )__ ?

Solution

TC++ #6334

__init__() is the class constructor or initialization method which is automatically invoked when we create a new instance of a class.
__del__() is a destructor which is automatically invoked when an object (instance) goes out of scope.
For Example:

class Sample:
    def __init__(self):
        self.data = 79
        print('Data:',self.data,'created')
    def __del__(self):
        print('Data:',self.data,'deleted')
s = Sample()
del s


Share

CSKC| Created: 11-Jan-2019 | Updated: 22-Feb-2019|CBSE12A-2015









Back