+ 1

What is the return type of constructor?

10th Nov 2016, 7:44 AM
Priyanka sundar
Priyanka sundar - avatar
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%
10th Nov 2016, 8:04 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 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
10th Nov 2016, 8:24 AM
Harish Nandoliya
Harish Nandoliya - avatar
+ 1
void, because constructor doesn't return anything.
10th Nov 2016, 7:49 AM
Rahul Chittimalla
Rahul Chittimalla - avatar
+ 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 !!
10th Nov 2016, 7:52 AM
Priyanka sundar
Priyanka sundar - avatar
10th Nov 2016, 7:56 AM
Rahul Chittimalla
Rahul Chittimalla - avatar
+ 1
thank you
10th Nov 2016, 7:59 AM
Priyanka sundar
Priyanka sundar - avatar
+ 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 !!!
10th Nov 2016, 8:25 AM
Priyanka sundar
Priyanka sundar - avatar
0
No return.
11th Nov 2016, 12:29 AM
Ceng Shaw
Ceng Shaw - avatar