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 does java final mean?
How does arraylist work in java?
When should you use arraylist and when should you use linkedlist?
How does singleton class work?
Can we declare a class as static?
Give the hierarchy of inputstream and outputstream classes.
What is an i/o filter?
What is another word for methodology?
Can you explain the usages of class.forname()?
What are data structures in java?
What is the final keyword?
If an object is garbage collected, can it become reachable again?
Does java support Operator Overloading?
What is a local class in java?
Why we use methods in java?