Difference between constructor and method

Difference between constructor and method

Constructor:

  • The constructor is used to initialize the state of the object.
  • The constructor must not have a return type.
  • Constructor name same as the class name.
  • The constructor does not support inheritance.
  • The constructor does not support overriding concept.

Method:

  • The method exposes the behaviour of an object.
  • The method must have a return type.
  • The method may or may not the same class name.
Posted on by