I read that "Constructors do not have a return type—not even void". BUT does it mean that constructors does not return any thing?
I believe that when a new instance is created the constructor call returns the handle/reference of that object. Is this true?
Basically, constructor is used to initialize instance variables within a class. No new instance variables are created. Rather, variables defined within the class can be set to a default value, such as 0 or 0.0 or something. No arguments are needed, and no 'return' statement is needed.
Seetharaman Venkatasamy wrote:Constructors logically return an object, but that is take care by JVM.
I don't think you should see it like that.
Constructors don't return anything. Constructors look like methods, but they are not really methods. A constructor is a special block of code that is called to initialise a new object. The constructor does not return the object, it just initialises the object that the JVM has created.