What is Constructor in JAVA

Fetching Comments ...

Constructor in java

Constructor is initializer block in class. This block call when class initialized. Constructor block called when instance of class is created. Without constructor we can’t create instance of that class. If we doesn’t create any constructor in a class then that class have a default constructor.

Key features of constructor:

  1. Constructor doesn’t have any return type.
  2. Constructor by default return instance of that class.
  3. Constructor called when instance of clasd is created. Constructor called before other methods.
  4. Constructor have same name as the class name.
  5. Constructor will look like method without return type.
Share This:

LearnPainLess On Instagram

Get The Best Of All Hands Delivered To Your Inbox

Subscribe to our newsletter and stay updated.