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
Write a program to check for a prime number in java?
How do you do descending order in java?
Why is the main method declared static?
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
What is thread synchronization in java?
Say any two properties in beans?
What are the 6 boolean operators?
How do you use compareto in java?
Garbage collection in java?
What is the Concept of Encapsulation in OOPS
Why spring singleton is not thread safe?
Does java allow default arguments?
When do we need to use internal iteration? When do we need to use external iteration?
what is object-oriented programming in java?
Explain when classnotfoundexception will be raised ?