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...

can we create a object in static block
class A
{
static {
A a=new A();
}
}

Answer Posted / kaushal mittal

Yes we can create a object in static block.
1- if there is no main method than it will compile easily but at run time it will throw exception
//Exception in thread "main" java.lang.NoSuchMethodError:
main
2- if we put main method inside the class then it will compile and run successfully and we will get object.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the components of swing in java?

986


What are the two key features of swing?

1028


What is the function of lightweight components used in swing?

1043


Is there any heavyweight component in swings?

1012


What is swing delegation event model in java?

1102


What are swings?

996


What does javax swing do?

996


What are the advantage of swing over awt?

1021


How to change button color in java swing?

979


What is pane in swing?

956


How to render an html page using only swing.

1010


What is actionlistener in java swing?

1051


What is import javax swing in java?

982


Can a class be it?s own event handler? Explain how to implement this?

1002


Why swing is better than awt?

1029