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

could you run the java program without main method?

Answer Posted / rammohan

with out main() and static block also run java program
through static obj creation
class nomainnostatic
{
nomainnostatic()
{
System.out.println("vaaniMohan");
System.out.println("hai");
System.exit(1);
}
static nomainnostatic n=new nomainnostatic();
};
support some jdk versions only
exp:when ever static obj is created the default constructor
will be called,so the constructor block will be executed.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the functionability stubs and skeletons?

1105


How does split work in java?

999


What is the purpose of the System class?

956


How does a for loop work?

953


How can we make sure main() is the last thread to finish in java program?

1152


Which collections are thread safe in java?

888


What is the difference between == and === javascript?

1100


What is the difference between variable & constant?

972


what is singleton class in java?

998


What is private static class in java?

974


Is a method a function?

1010


What is a parent class in java?

962


What are different types of references?

940


a thread is runnable, how does that work? : Java thread

944


What is integer size in java?

953