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 is the use of jfc in java swing?

1135


Explain the difference between awt and swt.

1086


Is swing thread-safe?

1042


What are the advantages of swing over awt?

956


What is layout in java swing?

1053


What is the function of abstractaction class?

1121


Where is java swing used?

1121


What is jfc swing in java?

1045


What's java swing?

1057


What is swing gui?

985


What is swing api?

1021


what are the steps required in creating an empty table drop?

1098


How does accessibility works in swings?

1018


How to move from one page to another in java swing?

1118


What is swing and its features in java?

1085