+ 1
What is the return type of constructor?
8 Answers
+ 4
Constructor is class type. It is use to initialized class for every new object created through that class. You cannot access constructor directly from object of that class. Thats why it has not any return type. All OOP languages have some magic words for example set or any initialized function do not return value they only accept value and set in in their private or any other type variables. Rahul is saying just another thing, you can say it is right but that is not 100%
+ 2
practically constructor return nothing not even void.
but actually it return instance of class.
so if you write....
String s = new String("Harish");
then constructor return address of string 'Harish' which is assigned to object s.
so then we can refers to that address using object s
+ 1
void, because constructor doesn't return anything.
+ 1
actually I heard that... implicitly the return type if the constructor must be the class type... I have doubt in that...is that rite or wrong !!
+ 1
Hope this link clears your doubt : http://stackoverflow.com/questions/2391233/return-type-of-the-constructor-in-c
+ 1
thank you
+ 1
wow!!! thank you Mr.Aditya Kumar . I have asked with so many ppl but I can't get clear answer like this!!! thank u so much . thanks to rahul too !!!
0
No return.



