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 a treemap in java?

957


What is the use of math abs in java?

969


What are the advantages and disadvantages of reference counting in garbage collection?

978


how to prepare for IT Officers Interview in Banks

1919


Explain different forms of polymorphism?

1100


What is a parameter in a function?

958


What is the purpose of javac exe?

1038


What does indexof mean?

957


When will you define a method as static in Java?

1002


What is callablestatement? How you can call stored procedure to pass in parameter?

985


What is final?

1013


What are the states of thread in java?

925


How do you declare a string variable?

967


What is namespace in java?

951


Is hashset ordered?

989