In Java why we write public static void main(String args[])
why not main()?
Answer Posted / manikandan
in java , the entry point for execution is Main(),
it is tha first method to be invoked .
so PUBLIC is declared for no duplicates should occur and for
global declaration .
VOID , the main method will not return any value . So void
is declared .
Finally STATIC , in java everything is accssed through
objects . But here main() is the first method to be invoked
. STATIC is defined for this purpose , If a method is
declared as STATIC it can called without any objects
reference .
So the Main() in java is defined as
public static void main(String args[])
Is This Answer Correct ? | 50 Yes | 15 No |
Post New Answer View All Answers
What is tcp and udp?
Why is a singleton bad?
Can an interface implement another interface?
Explain about abstract classes in java?
What is the abstract class?
What do you mean by access modifier?
What is pass by value?
What is the use of math abs in java?
Can we execute java program without main method?
When we should use serialization?
What is scope & storage allocation of static, local and register variables? Explain with an example.
Can constructor be protected in java?
Can a class be private or protected in java?
What is the difference between a vector & an array list?
How do you represent a space in regex java?