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
How can we achieve thread safety in java?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?
What is the function of compareto in java?
What is an example of a boolean?
Are private methods final?
Does importing a package imports its sub-packages as well in java?
Detail discussions on JVM, memory management and garbage collector.
Describe the Big-O Notation.
What is the difference between integer parseint and integer valueof?
What is a boolean in java?
Differentiate between the constructors and methods in java?
How would overload a function based on return type?
What is data type modifier?
What is main in java?
What differences exist between iterator and listiterator?