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.
- Constructor doesn’t have any return type.
- Constructor by default return instance of that class.
- Constructor called when instance of clasd is created. Constructor called before other methods.
- Constructor have same name as the class name.
- Constructor will look like method without return type.
Subscribe to our newsletter!
We'll send you the best of our blog just once a month. We promise.