Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is a static block?

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


Please Help Members By Posting Answers For Below Questions

What are the differences between this and super keyword?

928


What's the access scope of protected access specifier?

1018


What is the benefit of lambda expressions?

1040


Difference between operator overloading and function overloading

1047


How to write custom exception in java?

1039


What is private protected in java?

1022


What is hasnext in java?

1001


Does garbage collection occur in permanent generation space in jvm?

1068


Which package is always imported by default?

1085


How does arraylist work in java?

1096


What are design patterns and please explain?

1067


Where to store local variables?

1085


What is a priority queue java?

974


Under what conditions is an object’s finalize() method invoked by the garbage collector?

1020


Is break statement can be used as labels in java?

946