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 a private method of a superclass be declared within a subclass?
What is boolean keyword in java?
Name and explain the types of ways which are used to pass arguments in any function in java.
How can you read content from file in java?
How many types of memory areas are allocated by jvm?
List two java ide’s?
What is the point of java?
How does hashset work in java?
what state does a thread enter when it terminates its processing? : Java thread
What is the difference between inheritance and encapsulation?
Which class contains a method: cloneable or object?
Why lambda expression is used in java?
How is Object Oriented Programming different from Procedure Oriented Programming?
Does every java program need a main?
What is the name of the java compiler?