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 are the different ways to handle exceptions?

547


What does @override mean?

538


Is stringwriter thread safe?

557


What are Normalization Rules? Define Normalization?

556


What is use of super keyword in java?

607






What do you mean by inner class in java? Explain

594


What kind of variables can a class consist?

602


Difference between concurrent hashmap and hashtable and collections

570


What happens if we don’t override run method ?

573


How do you compare objects in java?

508


What is module in oop?

576


What does arrays sort do in java?

549


What is thread life cycle in java?

588


Is java a utf 8 string?

542


What is meant by attribute?

603