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 / shaik baji

Yes, we can execute the java program with out the main
method by using the the static block. After executing the
static block the JVM will search for the main method so to
skip this we should call System.exit(int) method.

NOTE: System.exit method contains integer parameter so we
shoud pass the integer value.
class MainDemo
{
static
{
System.out.println("hello i am visible without
main");
System.exit(0);
}

}

Is This Answer Correct ?    14 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is boolean false?

928


Explain about instanceof operator in java?

989


What do you mean by inner class in java?

1007


What is meant by object oriented programming – oop?

919


Is linked list a linear or non-linear data structure?

912


What is mean by encoding?

1019


Can I import same package/class twice?

892


How do you sort a list in java?

973


Define "Access specifiers" in java.

1119


What is purpose of keyword void?

981


What is percentage in java?

954


How do you calculate square roots?

1096


Can list contain null in java?

1028


Is it possible to override the main method?

925


Which is better ascii or unicode?

937