How many times is constractor required to developer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How many times is constractor required to developer?

In my opinion, It's useful

23rd Sep 2016, 3:18 PM
ismail tekin
ismail tekin - avatar
4 Answers
0
Constructor is used everytime you instantiate a class. Even if you don't see any constructor there. So it's essential.
23rd Sep 2016, 9:42 PM
Ivan G
Ivan G - avatar
0
constructor is called automatically when you make instance of that class....... constructor can be overloaded as much you want
24th Sep 2016, 7:15 AM
Muhammad Muneeb Ijaz
Muhammad Muneeb Ijaz - avatar
0
Constructor is not required. If you do not declare any. Compiler automaticly generete defualt one without any parameters.
24th Sep 2016, 10:13 AM
Daniel Dudziak
Daniel Dudziak - avatar
0
based on requirements you can use. let me give you one example that will be useful to understand. suppose , you have multilingual web site or Windows form project. now. when the user will logon to web or form application that he/she want to choose language. because in which language you want to open your site. so that time I will create constructor of whatever page will open after logon and choose Language. and you will get output on your chosen language. class Farmer { Farmer() { Decorate(): } private void Decorate() { // your preferred Lang. code goes here. } }
6th Oct 2016, 6:02 PM
Vijay Makwana
Vijay Makwana - avatar