0

Hello Everone,,,

Is it Compilsory to make constructors in java classes????

17th Aug 2019, 12:39 PM
Wasiq Abdullah
4 Answers
+ 6
Programmer{■} ➝ Java automatically provides a default constructor, so all classes have a constructor, whether one is specifically defined or not. https://www.sololearn.com/learn/Java/2157/
18th Aug 2019, 2:16 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 6
When we create the object then the constructor will be automatically called by the JVM. If you don't define any constructor, the compiler automatically creates a default constructor and assign default values for all your variables in the class. NOTE: If you define at least one constructor, the default constructor is not generated.
17th Aug 2019, 1:46 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 4
If you do not create a constructor, a default constructor which does nothing will be generated by your compiler.
17th Aug 2019, 12:44 PM
Hatsy Rei
Hatsy Rei - avatar
0
Hatsy Rei .when default constructor is generated...after that we need to call it or not??
18th Aug 2019, 12:50 PM
Wasiq Abdullah