In Java why we write public static void main(String args[])
why not main()?
Answer Posted / madhu
public static void main()
Public:-->The method is public because it be accessible to
the JVM to begin execution of the program JVM is outside of
the class.
Static:--> It is Static because it be available for
execution without an object instance. you may know that you
need an object instance to invoke any method. So you cannot
begin execution of a class without its object if the main
method was not static
Void:--> It returns only a void because, once the main
method execution is over, the program terminates. So there
can be no data that can be returned by the Main method
Main:--> Main() is the entry point of the program. Rather
we can say it is the main gate to enter inside the
apartment. It should be public because the compiler need to
enter inside the method (The guest need to access the
apartment to reach the security guard).
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you download stubs from Remote place?
Explain notifyall() method of object class ?
What is singleton pattern?
Why we use set in java?
What do u mean by variable?
What is a instance variable?
Is it necessary that each try block must be followed by a catch block?
What is charat ()?
What is a numeric format?
What is an object class?
How the metacharacters are different from the ordinary characters?
Write a java program that prints all the values given at command-line.
Can we clone singleton class in java?
Can an interface be defined inside a class?
What is methodological theory?