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
Can we call the run() method instead of start()?
How do you convert string to int in java?
What isan abstract class and when do you use it?
What is string example?
Are static members inherited to sub classes?
What are constants?
What is public/private protected in java?
What is a instance variable in java?
Is there any way to skip finally block of exception even if some exception occurs in the exception block?
Is singleton thread safe in java?
What is the list interface?
What do heavy weight components mean in java programming?
What is a void in java?
Tell us something about different types of casting?
Is it safe to install java on my computer?