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 8 primitive data types in java?

1022


Can I override protected method in java?

1079


How do you get length in java?

1036


Implement two stacks using a single array.

1071


What is the purpose of object oriented programming?

981


How does map works in java?

1007


Write a program to find the whether a number is an Armstrong number or not?

1034


What is hotjava?

1011


How many bits is size_t?

996


Do I need to import java.lang package any time? Why?

1391


Which data type is class in java?

1021


Can you run java program without main method?

1065


If you do not want your class to be inherited by any other class. What would you do?

1008


What is java objectoutputstream?

991


Can a class be defined inside an interface?

1035