In Java why we write public static void main(String args[])
why not main()?

Answer Posted / kanchan bangar

In java if we are not writting public static void main
(String args[]) then program is only compield not run
that's why it must write because compiler in java always
look the main function and when compiler always calls the
main class is loaded in frist time call for that static
keyword is used and public is for access everything means
methods and member variabls of any pakage and classes or in
super class and meand it does not return any value.

Is This Answer Correct ?    18 Yes 57 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is static block?

598


we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.

1580


In java, what is the difference between method overloading and method overriding?

591


How do you read a char in java?

469


How do I stop concurrentmodificationexception?

519






What is the purpose of sizeof operator?

540


What is Classloader in Java?

642


What is a variable simple definition?

589


What are the differences between forwarding () method and sendredirect() methods?

631


What is thread count in java?

555


What is the difference between heap memory and stack memory?

626


Can we sort array in java?

536


How do you create a method in java?

553


What do you mean by scope of variable?

493


What is the synonym of framework?

568