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 passing by reference in java?

961


What is anti pattern in java?

898


Can a serialized object be transferred via network?

895


Why do we use predicate in java?

998


How does finally block differ from finalize() method?

998


State one difference between a template class and class template.

1021


Can we create a class inside a class in java?

990


Write a program in java to create a doubly linked list containing n nodes.

906


What are the important features of Java 10 release?

953


What are java packages? What's the significance of packages?

1218


What is equlas() and hashcode() contract in java? Where does it used?

1051


Which package is imported by default?

1031


What is the java idl system?

984


Why is stringbuffer faster than string?

867


How to sort an array in java without using sort method?

844