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
What is singleton class example?
What is java command?
Explain the importance of throws keyword in java?
What is java used for on a computer?
What is the purpose of the System class?
What is difference between equal and == in java?
What are the main uses of the super keyword?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
What exceptions occur during serialization?
What data type is string java?
Explain the difference between comparator and comparable in java?
How do you detect memory leaks?
What is final keyword in java? Give an example.
What is bean? Where it can be used?
What are 3 boolean operators?