what is a static block?

Answers were Sorted based on User's Feedback



what is a static block?..

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

what is a static block?..

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

what is a static block?..

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

what is a static block?..

Answer / ravikiran

static block is used to initialization during the JVM start
up

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is logical variable?

1 Answers  


how to create daemon thread in java?

1 Answers  


What is method overloading in JAVA? Why is it not present in C ?

1 Answers   Akamai Technologies,


What is difference between static and abstract class?

1 Answers  


What is size of int in java?

1 Answers  


IS method overriding is Duplication of Methods?

5 Answers   CybAge,


What is the major advantage of external iteration over internal iteration?

1 Answers  


What is null statement?

1 Answers  


Is java a virus?

1 Answers  


How do you classify Dialog Box?

1 Answers   CGI,


What is 'finally' method in Exceptions?

4 Answers  


What are multiple inheritances? Is it supported by java?

1 Answers  


Categories