Constructor:

  • It is a special method that is automatically called when an object of a class is created.
  • Example: A class Person may have a constructor to initialize attributes like name and age when an object is created.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *