In Java why we write public static void main(String args[])
why not main()?
Answer Posted / anjani kumar jha
Use of Public-----There is always only one main class that
is one file having only one main file. Since that main file
is used anywhere means might be in another package so there
is a public use of keyword that is public keyword is
required for main function
Static:-----Since compiler in java always look the main
function and when compiler always calls the main so main
class is loaded in first time call for that static keyword
is used.
you can use
1)public void main(String args[])
it compiles file but wont run\
2) void main(String args[])
it compiles file but wont run
3)void main(String args[])
it compiles file but wont run
Is This Answer Correct ? | 87 Yes | 37 No |
Post New Answer View All Answers
What is instance synchronization?
Can arraylist hold different types java?
What is arraylist e in java?
What is not thread safe?
What are peerless components in java programming?
How do you allocate memory to object?
What is a map in java?
What is static data type in java?
How do you override a variable in java?
What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?
Why string objects are immutable in java?
Tell me about different OOPS concepts.
What is difference between hashset and hashmap in java?
Explain about oops concepts.
whar are the draw backs of programming lang step by step in Clang and next in C++ and next and in Java nad in .Net