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 difference between math floor and math round?
What is boolean law?
Is main a keyword in java?
What is data type in java?
What is the final access modifier in java?
Give us a program to check for parenthesis matching using stack.
How do you check if a number is a perfect square?
What do you mean by of string::valueof expression in java 8?
Can there be an abstract method without an abstract class?
What is difference overloading and overriding?
Difference between default and protected access specifiers?
Why set is used in java?
Can a lock be acquired on a class in java programming?
What is function declaration?
What is the integer of 16?