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

Answer Posted / pandurang d billavar

for execution of class in java is done by creating a object
for methods of that class.so main method is also a class
method.so this method is called by jvm directly without
creating object for main method.it is possible only if main
is static.............so we maked main as static.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you access non static variable in static context?

559


What are abstract methods in java?

655


Can a final variable be manipulated in java?

534


Difference between character constant and string constant in java ?

559


Can we execute java program without main method?

524






Which variables are stored in heap?

543


What is the declaration statement?

516


Can you pass by reference in java?

528


Can we have two methods in a class with the same name?

585


I want my class to be developed in such a way that no other class (even derived class) can create its objects. Define how can I do so?

698


When a lot of changes are required in data, which one should be a preference to be used? String or stringbuffer?

767


How does java pattern compile work?

548


What is difference between class and object in java?

531


Can private members of a base class are inheritable justify?

488


Is finalize() similar to a destructor?

554