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 non static block in java

Answer Posted / sujay

An instance block in a java program can be said to be a
non-static block. The scope of a static block is same as the
scope of that class, It will be loaded into the memory when
the class is loaded into the memory and unloaded at the time
of class unloading. But the scope of an instance
block(non-static block) is same as the scope of the object
of that class, it will be loaded into the memory when every
an objected is created and destroyed when that object is
destroyed. So, static block is created only once at the time
of class loading and globally available to all the objects
of that class where as a separate copy of instance block is
created for each object.
class MyClass
{
static
{
System.out.println("I am static, available for all
the objects of this class!");
}

{
System.out.println("I am non-static, available as a
separate copy for each object that is created from this
class!");
}
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is overriding in java?

998


When should we create our own custom exception classes?

969


What is the byte range?

987


What is OOP Language?

1025


Tell some latest versions in JAVA related areas?

934


Difference between object and reference?

1126


Why is java architectural neutral?

1068


What is a dynamic array in java?

1113


What are keyboard events?

1102


What is the use of toarray () in java?

1019


Is it possible to write a regular expression to check if string is a number?

976


What is application tier?

1055


What is the difference between import java.util.date and java .util?

1010


What is the final access modifier in java?

1015


Are registers volatile?

897