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 / anjani kumar jha

Use of Public-----There is always only one main class that
is one file having only one main file. Since that main file
is used anywhere means might be in another package so there
is a public use of keyword that is public keyword is
required for main function

Static:-----Since compiler in java always look the main
function and when compiler always calls the main so main
class is loaded in first time call for that static keyword
is used.
you can use
1)public void main(String args[])
it compiles file but wont run\

2) void main(String args[])
it compiles file but wont run

3)void main(String args[])
it compiles file but wont run

Is This Answer Correct ?    87 Yes 37 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is functional interface in java?

1037


Is special character in java?

1091


How to print an arraylist in java?

1065


Can two objects have same hashcode?

992


What is the difference between member variables initialization and assignment in a constructor?

1249


Does constructor return any value?

1018


What class allows you to read objects directly from a stream in java programming?

1062


When a lot of changes are required in data, which one should be a preference to be used? String or stringbuffer?

1234


What are class members by default?

1072


Give an example of call be reference significance.

1025


Is it possible to override the main method?

971


When do we use hashset over treeset?

1043


Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?

1607


Can we overload the constructors?

985


What is the abstract class?

1018