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

Write a program to check for a prime number in java?

987


How do you do descending order in java?

906


Why is the main method declared static?

1071


Find the value of a specified element of the array arr[i] where 0 <= i <= n-1

922


What is thread synchronization in java?

857


Say any two properties in beans?

1017


What are the 6 boolean operators?

1016


How do you use compareto in java?

922


Garbage collection in java?

948


What is the Concept of Encapsulation in OOPS

935


Why spring singleton is not thread safe?

955


Does java allow default arguments?

943


When do we need to use internal iteration? When do we need to use external iteration?

1058


what is object-oriented programming in java?

996


Explain when classnotfoundexception will be raised ?

979