In Java why we write public static void main(String args[])
why not main()?
Answer Posted / ankur
in java we write public static void main(String args[])
instead of just main because:....
public.....The main method must be public because it is
call from outside the class. It is called by jvm.
static....The main method must be static because without
creating an instace jvm can call it. If the main method is
non static then it is must to create an instance of the
class.
void....Main method doesn't return anything therefore it is
void also.
(String args[])....It is used for receiving any arbitirary
number of arguments and save it in the array.
Is This Answer Correct ? | 429 Yes | 20 No |
Post New Answer View All Answers
Why do we use return statement?
What is identifier in java?
What is flag in java?
What is singletonlist in java?
What is difference between array and vector?
Why hashcode is used in java?
What are the principle concepts of oops?
Explain the importance of finally over return statement?
What is the final class modifier?
What does the “static” keyword mean?
What is string variable?
Is a class an object?
Can you access non static variable in static context?
Is java code slower than native code?
is it possible to instantiate the math class?