In Java why we write public static void main(String args[])
why not main()?
Answers were Sorted based on User's Feedback
Answer / sai kiran varma
In java main() is a default calling funtion.
first main() function is called.
As we dont no what value it returns we use void keyword for it.
only static methods can be called using class names so we
declare static.
only public methods can be accessed from any where so,we use
public..
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / lotus
as compiler needs to enter inside a program to compile so
public is used and static is used to help the main method
to be invoked without an object.
| Is This Answer Correct ? | 3 Yes | 7 No |
Answer / sreenu karampudi
public static void main(String args[])
When the class get loaded, it will execute the static main
() method. void as it does not return anything.
| Is This Answer Correct ? | 15 Yes | 49 No |
Answer / kanchan bangar
In java if we are not writting public static void main
(String args[]) then program is only compield not run
that's why it must write because compiler in java always
look the main function and when compiler always calls the
main class is loaded in frist time call for that static
keyword is used and public is for access everything means
methods and member variabls of any pakage and classes or in
super class and meand it does not return any value.
| Is This Answer Correct ? | 18 Yes | 57 No |
Answer / ivan
Because in java every thing we enter is accepted as a
string.
| Is This Answer Correct ? | 73 Yes | 163 No |
what is mean by String and StringBuffer? What is mean by Methooverriding and Overloading?
What is a method in java?
What is an event?
What is the differences between heap and stack memory in java? Explain
how many ways to create Thread and which one is good? runnable interface ot Thread class?
What is the difference between an argument and a parameter?
Is class forname reflection?
int a=1; float b=1.0; System.out.println(a==b);
13 Answers CTS, Honeywell, McAfee,
What is final, finally, finalize?
How does arraylist size increase in java?
what is aberivation of java?
How to declare objects of a class ?
0 Answers Akamai Technologies,