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

Answer Posted / kedar

static methods can be accessed without creating object object of class, we know that file name of java program is "classname.java", "classname" is the class which contain main function, so it is easier for compiler to locate class which contain main(), and because of static nature it can execute it.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the integer of 16?

539


How does hashset works in java?

535


Can a main method be declared final?

588


What restrictions are placed on method overloading?

612


Do loops java?

556






What is object class in java?

505


Can you extend main method in java?

624


What is method overloading with type promotion?

581


If we don’t want some of the fields not to serialize how to do that?

567


What is array pointers ?

607


Is it possible to override private or static method in java?

546


Why is java architectural neutral?

617


What are the restrictions imposed by a Security Manager on Applets?.

2067


what is difference between equals and ==?

590


What is the difference between the prefix and postfix forms of the ++ operator?

556