0
Does constructor return any value?
java
6 ответов
+ 7
Ipang, thank you very very much.
I will read it
+ 6
Ipang, I agree with you.
But I have seen the right answer in quiz here is that constructor returns value.
I'm confused about this.
+ 6
Ipang, certainly.
If I have see it again, I will share it here
+ 3
Dmitry I myself am still uncertain, but I was thinking the 'new' operator is responsible for instantiating an new object, and the constructor is then invoked behind the scenes to setup the new object's members values. Perhaps these links can explain better : )
https://docs.oracle.com/javase/tutorial/java/javaOO/objectcreation.html
https://stackoverflow.com/questions/14737420/what-does-a-constructor-return-in-java
+ 2
To my understanding constructors are used to initialize/prepare a class instance's members on creation/instantiation, setting a predefined/default values for the members, so I guess it doesn't return anything, and the constructor doesn't use 'return' statement either, which also indicated that nothing was returned, but I could be wrong : )
Hth, cmiiw
+ 1
Dmitry No problem mate, btw can you please take a screenshot of the quiz and the correct answer, where it says constructors can return something, I begin to doubt the quiz a little.
Thanks : )