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


Please Help Members By Posting Answers For Below Questions

What is tcp and udp?

608


Why is a singleton bad?

564


Can an interface implement another interface?

580


Explain about abstract classes in java?

592


What is the abstract class?

603






What do you mean by access modifier?

561


What is pass by value?

517


What is the use of math abs in java?

554


Can we execute java program without main method?

526


When we should use serialization?

572


What is scope & storage allocation of static, local and register variables? Explain with an example.

572


Can constructor be protected in java?

514


Can a class be private or protected in java?

560


What is the difference between a vector & an array list?

677


How do you represent a space in regex java?

529