In Java why we write public static void main(String args[])
why not main()?
Answer Posted / anil chahal
We write main method as static because we call this method
from class name. We are not instancing by making its object
so if we call from class name we must have to write static .
we write void because main method is return nothing.Public
because there is always only one main class that is one file
having only one main file, because this main file may be
used anywhere means
outside this package so public keyword is must.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is void keyword?
There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?
Difference between a process and a program?
What is not object oriented programming?
What is wrapper class example?
What is the difference between math floor and math round?
What about interrupt() method of thread class ?
What does %d do in java?
What are the differences between path and classpath variables?
What is the meaning of find and replace?
Why map is used in java?
What is use of static in java?
How do you test a method for an exception using junit?
what is singleton in java?
Difference difference paint() and paintcomponent()?