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

Does java support multiple inheritances?

1022


What is the difference between quicksort & mergesort? When should they be used? What is their running time?

1089


What are the core java topics?

1048


What is a buffer in computer?

1004


What is return in java?

969


What value is a variable of the string type automatically initialized?

1114


How to remove the trailing spaces from a string?

1274


How can you share data between two thread in Java?

945


What is java in layman terms?

1012


What do you mean by an interface in java?

1029


What is the purpose of void?

996


What initialize variables?

1022


Why singleton is not thread safe?

992


What are the types of java?

1106


How can we make a class singleton?

1073