I understand that there are three parts to object creation:
- Declaration
- Instantiation
- Initialization
classA{}
classB extends classA{}
classA obj = new classB(1,1);
Instantiation
It has to create an object using new operator
and this object must have all the fields related to classB (initialized to default values does this step give a call to default constructor?) this is instantiation
does it mean this step is initialization using java's default constructor?
Initialization
this object is then passed down the hierarchy giving calls to various constructor in the way to get initialized (which comes under initialization) and the final obj is created by 'classB(1,1)` constructor whith required Initializations
but how is the object mentioned in instantiation step being created initially with all available fields?
please point out if anything i said is wrong
... give a call to default constructor?No. There is not necessary any default constructor for a class. It simply means that the memory is allocated and all members are initialized with default values. 2.... final object is returned to...constructor which retruns final objectConstructor is not returning anything