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
Explain the importance of finally block in java?
What is the purpose of object oriented programming?
What is the preferred size of a component in java programming?
What is tree node in java?
What are recursive functions? Give some examples?
What is class and its types?
What is appletviewer?
Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.
What is the tradeoff between using an unordered array versus an ordered array?
there are N number of matchboxes numbered 1...N.each matchbox contain various number of stick.Two player can alternatevely pick some amount of stick from the higest stick containing box . The player is condidered win if there is no stick after his move.Find the final move so that the move player win. Note:In case the number of stick is equal ,pick the stick from the higest numbered box.
Can java cast null?
How to stop a thread in java? Explain about sleep () method in a thread?
Is java a utf 8 string?
What is ‘has a’’ relationship in java?
What restrictions are placed on method overriding in java programming?