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

Answer Posted / amardip sabale

we write public static void main() because
public:for access of main function all over the program
static:main is also one type of method,and for calling this
method while running our program without creation of any
object
void:because it is not return anything
String args[]:because when we run our program then always
we pass at least two command line arguments(java and
program name)for collecting them we have to write it
*THANKS*

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to find maximum and minimum number in array?

553


Can a class be defined inside an interface?

565


Is final static java?

551


Explain where variables are created in memory?

585


What is variable and its types?

545






Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

555


Can we use this () and super () in a method?

533


How an object is serialized in java?

530


what is thread in Java ?

629


What is an argument java?

539


Can we declare a class as abstract without having any abstract method?

557


If an application has multiple classes in it, is it okay to have a main method in more than one class?

538


Difference between predicate, supplier and consumer ?

585


How do you declare a string variable?

522


What is jvm? How its run?

664