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

Answer Posted / xyz

Public -> Because we want to access the main from the out side of the class generally when we run the java program at that time it call the main method.

Static ->Because it will create only one copy of main method and we can call with class name so when we run program it will
run main method using passed program name like name.main();

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 byte [] in java?

538


Difference between operator overloading and function overloading

613


What is difference between path and classpath?

564


What do you understand by abstract classes?

603


What is java instanceof operator?

564






How many bits is a string?

525


Can long be null in java?

546


What types of index data structures can you have in java?

614


How do singleton patterns work?

519


What purpose do the keywords final, finally, and finalize fulfill?

614


What is the purpose of a parameter?

531


What are the procedures?

610


How do I convert a string to an int in java?

553


What access modifiers can be used for methods?

562


Which class is the superclass of all classes?

602