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 indent key?
What are the different access modifiers available in java?
What is default switch case? Give example.
How big is a boolean?
What is a “stateless” protocol ?
What is the difference between a break statement and a continue statement?
How to compare two strings in java program?
What are classloaders?
Where to store local variables?
Is java util list serializable?
How do you sort a string in alphabetical order in java?
Write a factorial program using recursion in java?
please send me hr interview questions in it industry
What is quick sort in java?
What is java util function?