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 a marker interface?
What are the important features of Java 9 release?
Can we assign the reference to this variable?
Will the jvm load the package twice at runtime?
What do you mean by compiler?
Is java free for businesses?
What is a void in java?
What is the replace tool?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
What are the different types of constructor?
What are the 6 mandatory procedures for iso 9001?
What is function overriding and overloading in java?
Can You Have Virtual Functions In Java?
What is the longest unicode character?
How to check if a list is sorted in java?