aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Creation of Object Q Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Creation of Object Q" Watch "Creation of Object Q" New topic
Author

Creation of Object Q

Nitin Bhagwat
Ranch Hand

Joined: Sep 09, 2004
Posts: 132
Following code works fine. Question is how value of av is available before completion of constructor? (I think, class members - methods and variables (except static) are available only after completion of constructor). Please correct if i am wrong.



"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Nitin Bhagwat:
I think, class members - methods and variables (except static) are available only after completion of constructor


Instance members are actually initialized prior to the constructor being executed so all instance members are available within the constructor.


SCJP Tipline, etc.
Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
Hi Nitin,
The concept is this. Consider a base class and derived class has static initialiser block and instance initialiser block. The order of execution is as follows :
===
STATIC Instance Initialiser - Base
STATIC Instance Initialiser - Derived
Instance Initialiser - Base
Parent cons. called
Instance Initialiser - Derived
Constructor of derived
===
Below is a code. Try that and you will get it.


Cheers!
_Mani


Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
Nitin Bhagwat
Ranch Hand

Joined: Sep 09, 2004
Posts: 132
Thank you Mani, Excellent help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creation of Object Q