what is a static block?
Answers were Sorted based on User's Feedback
Answer / madan
static block contains a code which is executed without
object of a class.i.e is excuted at the time of class
loading
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / 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 |
Answer / srinivasa
Static block is executed when the class is loaded into the
memory before the main(). Only once it will be executed.
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / ravikiran
static block is used to initialization during the JVM start
up
| Is This Answer Correct ? | 1 Yes | 1 No |
What is the difference between jfc & wfc?
What is unsigned char?
What is the purpose of file class?
Differece between class and generic class?
Explain the different forms of polymorphism?
Explain the usage of this with constructors?
What is the immediate superclass of the Dialog class?
How many types of syncronization?
how to create constants in java?
Why wait(),notify(),notifyAll() methods defined in Object class althought we are using in only threads.
What is the differnence between String Buffer and String builder despite having knowledge that String builder is faster than String Buffer and last one is threadsafe.please tell another important difference.
How many bits is a word?