Answer Posted / ranganathkini
A static block or a static initializer is a block that
appears within a class definition but outside any member
definition with the keyword static ahead of it. Example:
class MyClass {
private static double myValue;
static {
myValue = Double.parseDouble( System.getProperty(
"version" ) );
}
}
It is mainly used to perform static construction i.e.
initialization of static variables (see above example). The
static initializer is executed when the class is loaded by
the JVM.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Explain about the interpreter in java?
What is Applet Stub Interface ?
How do you convert boolean to boolean?
Can you instantiate the math class in Java?
Is void a return type?
Can arraylist contain null values?
What is an infinite loop? How infinite loop is declared?
Define packages in java?
What is the difference between Java1.4 and Java1.5
What are the steps involved to create a bean?
What are assembly attributes?
What is the purpose of a parameter?
How many bits is a boolean?
What an i/o filter?
What are the main differences between notify and notifyAll in Java?