can constructors be called?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can constructors be called??

9th Sep 2016, 9:11 PM
sourabh patel
sourabh patel - avatar
3 Answers
+ 2
You call a constructor when instanciating an object. MyClass myObj = new MyClass();
9th Sep 2016, 10:20 PM
Zen
Zen - avatar
+ 1
yeah, constructor can be called when an object is created
11th Sep 2016, 5:17 PM
Dheeraj Reddy
Dheeraj Reddy - avatar
+ 1
constructor cannot be called explicitly they are automatically called when the object is created
13th Sep 2016, 8:41 AM
Gourav Dhoot