In Java why we write public static void main(String args[])
why not main()?
Answer Posted / priyanka
DECRIPTION ABOUT PUBLIC:
The main method should be acceseible to every function
which is inside the package and outside the package. and it
is possible only if main method is declared as public
DECRIPTION ABOUT STATIC:
Static is a storage class. static allocates space for
its data and it is first step done after compilation. In
java main method is coded inside a class.. but compiler
need to call the main method first as it is one of the
protocol in ANSIC..
A method in the class without creating an instance can
be called only if the method is static.. so main method
should be static
DECRIPTION ABOUT VOID:
As main method returns nothing or empty main is declared
as void
DECRIPTION ABOUT STRING(ARGS[]):
In java every input is considered as string. even the
input is of integer type it is taken as string. so main
takes arguments of type string.
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
What do you understand by looping in java? Explain the different types of loops.
Which api is provided by java for operations on set of objects?
What are wrapper classes in java?
What does isempty () do in java?
Can classes declared using the abstract keyword cab be instantiated?
Which variable is the independent variable?
Why is it called a string?
Can we have multiple classes in a single file?
Explain about the select method with an example?
What is args length in java?
What is the size of boolean variable?
How to Sort Strings which are given in List and display in ascending order without using java api.
Which is a valid identifier?
Variable of the boolean type is automatically initialized as?
What is string in java is it a data type?