In Java why we write public static void main(String args[])
why not main()?
Answer Posted / b.prasad
1.we should give public bcoz the main() used my all
applications that r out side of application
2.we should give static bcoz it is instance method.so that
with out creating an object we can call it directly.and the
definition of the method should not been changed
3.we should give void bcoz the main() does not return any
value.ie void means return nothing
4.we should give args[],bcoz the main method takes some
arguments in the command prompt that are the string type and
also the jvm defines the signature of the main() is like that
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Explain the importance of throwable class and its methods?
Add a value x to array from index l to r where 0 <= l <= r <= n-1
How does java pattern compile work?
What is composition in java?
What is the difference between checked exception and unchecked exception?
What are the benefits of operations in java?
What does this () mean in constructor chaining concept?
How objects are stored in java?
Why do we need hashmap in java?
a thread is runnable, how does that work? : Java thread
What are the approaches that you will follow for making a program very efficient?
What do you mean by ordered and sorted in collections in java?
What is your platform’s default character encoding?
What is the difference between class & structure?
How can I right-justify a string?