Nancy Antony wrote: when I donot write any constructor in my class Java provides one, which we usually say that intializes the instance variables to their default values
but I think default construtor doesn't do anything as any variable screated on heap is automatically initialized, am I right?
What does constructor returns ? Current Object i.e this that means object reference as this is a reference to the current object. So I understand the process as such. new allocates memry and constructor is called by passing this to the constructor and the only code which is present in default constructor is return this and in paramterized constructor , return this statement is automatically added?
Nancy Antony wrote:I think default construtor doesn't do anything as any variable screated on heap is automatically initialized, am I right?
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg wrote:
Then after compilation this code would look something like this
Astha - OCPJP 6 (90%)
Bharaathi Jagadisan wrote:why the constructor doesn't return any values
Jesper de Jong wrote:cats just don't ride bicycles
Joanne
Astha Sharma wrote:
Objects are formed at run time not at compile time. Then how can instance variables be initialized at compile time before instance of class is formed? Are they initialized at the time when class is loaded?