This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Instance Initializer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Instance Initializer" Watch "Instance Initializer" New topic

Instance Initializer

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
When a class gets loaded? What happens when the constructor is called? When is static block gets called? What is an instance initializer block?

David Byron

Joined: Jan 20, 2009
Posts: 172


SCJD 6, OCPJP7, Baroque Potion, G+
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1660

Understanding the order of operation for how a class gets loaded is really important.

Always remember Static blocks and members load before any instance members get loaded. Anything static gets loaded top to bottom.
Constructors always make a call to super() before doing their thing.

When you do things right, people won't be sure you've done anything at all.
I agree. Here's the link:
subject: Instance Initializer