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
If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?
explain multi-threading in java?
What is the difference between throw and throws keywords?
What is the definition of tree ?
What is the argument in java?
Can we extend immutable class?
Can we declare a constructor as final?
Are strings immutable in java?
What is qms certification?
What is exception in java?
According to java operator precedence, which operator is considered to be with highest precedence?
What are the 3 types of loops in java?
What is string pool?
Write an algorithm for quick sort?
What is multithreading in java?