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

In Java why we write public static void main(String args[])
why not main()?

Answer Posted / ankur

in java we write public static void main(String args[])
instead of just main because:....

public.....The main method must be public because it is
call from outside the class. It is called by jvm.

static....The main method must be static because without
creating an instace jvm can call it. If the main method is
non static then it is must to create an instance of the
class.

void....Main method doesn't return anything therefore it is
void also.

(String args[])....It is used for receiving any arbitirary
number of arguments and save it in the array.

Is This Answer Correct ?    429 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does java final mean?

1118


How does arraylist work in java?

1164


When should you use arraylist and when should you use linkedlist?

978


How does singleton class work?

1035


Can we declare a class as static?

1144


Give the hierarchy of inputstream and outputstream classes.

1158


What is an i/o filter?

1959


What is another word for methodology?

1074


Can you explain the usages of class.forname()?

1113


What are data structures in java?

1028


What is the final keyword?

1033


If an object is garbage collected, can it become reachable again?

1065


Does java support Operator Overloading?

1088


What is a local class in java?

1085


Why we use methods in java?

1046