In Java why we write public static void main(String args[])
why not main()?
Answer Posted / rahul
The public keyword is an access specifier, which allows the
programmer to control the visibility of class members. When
a class member is preceded by public, then that member may
be accessed by code outside the class in which it is
declared.In this case, main( ) must be declared as public,
since it must be called by code outside of its class when
the program is started.
The keyword static allows main( ) to be called without
having to instantiate a particular instance of the class.
This is necessary since main( ) is called by the Java
interpreter before any objects are made.
The keyword void simply tells the compiler that main( )
does not return a value. As you will see, methods may also
return values.
about strings[] It takes no of arguements & stored in an
array ,input is of integer type it is taken as string. so
main takes arguments of type string.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a nested structure?
What are class types in java?
Why is a singleton bad?
What is main method?
What are 3 data types?
What is thread life cycle?
What is mnemonic in assembly language?
What access modifiers can be used for methods?
What does @param args mean in java?
What is classpath?
Why for each loop is used?
What is a wrapper method?
How do you insert a line break?
Is string is a data type?
Why main method is called first in java?