Previous

Differences between Method & Constructor

Next
Method Constructor
  • Method Name can be any name.
  • Constructor name should be __init__()
  • Methods won’t be executed automatically, we have to call explicitly, then only methods will be executed.
  • Constructors will be executed automatically whenever we are creating an object and we are not required to call explicitly.
  • Per object, we can call method any number of times.
  • Per object constructor will be executed only once
  • Inside method, we can write business logic based on our programming requirement.
  • Inside constructor we have to declare and initialize instance variables.