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
What is the use of using enum to declare a constant?
What do you mean by global variable?
What is the use of java?
What is the difference between procedural and object-oriented programs?
Why are getters and setters used?
How do you find the independent variable?
Tell us something about different types of casting?
What is ternary operator?
Is arraylist ordered in java?
What is composition in java?
What is size_t?
Can I declare a class as private?
Which object oriented concept is achieved by using overloading and overriding?
What is a null point?
Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.