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 the hashcode () and equals () used for?

951


Whats the difference between notify() and notifyall()?

967


What is the difference between public, private, protected, and friend access?

987


What's the purpose of static methods and static variables?

1032


Can we have a method name same as class name in java?

991


Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.

970


What is floor in java?

983


Define the term string pool?

951


How do you use substring in java?

1053


how can you catch multiple exceptions in java?

967


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

906


How to print an arraylist in java?

997


Explain about wait() method?

973


What is Java Reflection API? Why it’s so important to have?

1072


Difference between comparator and comparable in java?

1028