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 / madhu

public static void main()

Public:-->The method is public because it be accessible to
the JVM to begin execution of the program JVM is outside of
the class.

Static:--> It is Static because it be available for
execution without an object instance. you may know that you
need an object instance to invoke any method. So you cannot
begin execution of a class without its object if the main
method was not static

Void:--> It returns only a void because, once the main
method execution is over, the program terminates. So there
can be no data that can be returned by the Main method

Main:--> Main() is the entry point of the program. Rather
we can say it is the main gate to enter inside the
apartment. It should be public because the compiler need to
enter inside the method (The guest need to access the
apartment to reach the security guard).

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is flush () in java?

967


Can list be final in java?

875


Write a java program for binary search?

1013


What are the two ways in which thread can be created?

1010


Is java free for commercial?

870


Is 0 a real number?

977


What are the two parts of a conditional statement?

920


Explain the difference between string, stringbuffer and stringbuilder in java?

964


What is the difference between static method and instance method in Java?

1138


What does percent mean in java?

977


What is difference between throw and throws ?

1085


why java uses class level type casting ?

2617


If goto and const is reserve words than why it is not work in java?

1923


Can we declare main () method as non static?

930


Is object a data type in java?

1059