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

Answer Posted / srinivas_cena

public- public isa access specifier,so we can use the method from out the class
static- static is a keyword which is used to calla methos with out creation of object for a class. so jvm directly runs from main() method.
void- main() method does not return any value so it has void data type.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between serial and throughput garbage collector?

587


Why enumeration is faster than iterator?

529


Is it necessary that each try block must be followed by a catch block?

561


What's the difference between an abstract class and interface in java?

560


What are different types of control structures?

495






Can this keyword be used to refer static members?

547


What is a super method?

534


Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?

562


Can you explain inner class.

596


What is the difference between char and char *?

567


What is an interoperable application in java ?

586


How do you replace all in word?

533


Can a class be private or protected in java?

558


What is arrays fill in java?

547


What is data type in java?

487