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

Answer Posted / preetham m.s.

he main method is the first method, which the Java Virtual
Machine executes. When you execute a class with the Java
interpreter, the runtime system starts by calling the
class's main() method. The main() method then calls all the
other methods required to run your application. It can be
said that the main method is the entry point in the Java
program and java program can't run without this method.

The signature of main() method looks like this:

public static void main(String args[])

The method signature for the main() method contains three
modifiers:

public indicates that the main() method can be called by
any object.
static indicates that the main() method is a class method.
void indicates that the main() method has no return value.

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 bigger kb or mb?

587


State differences between C and Java?

666


What is locale in java?

579


When should a function throw an exception?

599


Can we compare two strings in java?

559






How long will it take to learn java?

509


What is the default value of byte datatype in java?

487


What is the base class of all exception classes?

586


What are static blocks and static initalizers in java ?

587


When will we prefer to use set and list in java and why?

550


How will you serialize a singleton class without violating singleton pattern?

1525


What is the purpose of the enableevents() method?

585


Differences between C and Java?

620


what are the states associated in the thread? : Java thread

593


Is java good for beginners?

583