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

How many inner classes can a class have?

1039


Explain about object oriented programming and its features?

1005


What is unicode full form?

974


Can we define a package statement after the import statement in java?

1061


Why can't you declare a class as protected?

1125


What does the @override annotation do?

1032


Is it possible to use string in the switch case?

1039


What is the final keyword denotes?

1109


Can we define static methods inside interface?

974


Describe different states of a thread.

997


What is an empty string in css?

1043


Is vector ordered in java?

990


Write a program to calculate factorial in java?

997


How would overload a function based on return type?

951


Explain the hierarchy of java exception classes?

1086