What is static initializer block? What is its use?

What is static initializer block? What is its use?

After method and constructor, Initialization blocks are the third place where the operations can be performed. Initialization block do not have identifier and they are of two types :

  * Instance initialization block.
  * static initializaton block. 
 
Static initialization block starts with the keyword static with opening and ending curly braces. Static initialization block is used to initialize the static variable of the class because they are available before any instance created of the class i.e. before executing the constructor. Hence static initialization block are the right place to initialize the static variable. 

By:Jalees
Date:2015-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher