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

Answer Posted / prabhakant prabhakar rasal

We write public because to access main() method outside the
class.
Why static because to invoke main() method before creating
any object, so it simple to compiler that to identify the
main() method.
void, it represents that it does not returns any value.
string args[]
There are two main reasons to write string args[]
1. TO identify the program
2. To get command_line arguments

Is This Answer Correct ?    27 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is interface in java? Explain

536


What are the special characters?

538


What is palindrome in java?

562


What are keywords in java?

583


What is function declaration?

534






How many bytes is a string in java?

535


What is balanced tree in java?

536


when should you use stringbuilder class in a program?

528


What is jpa specification?

539


What is the indent key?

594


What is contract between hashcode and equal method?

576


Can we modify the throws clause of the superclass method while overriding it in the subclass?

553


What variables are stored in stack?

533


What is multiple inheritance? Is it supported by java?

530


What are different types of control structures?

495