Why do we use public static with the main function in Java?
Answer Posted / balaji kumar
public - it can be access outside of the(class, package,
subclass and world).
Static- It is used to run a method without any references of
a class. Then JVM will check all the 'static' methods in
"main class" and run the main method from those.
void- main method always has no return value to outside
methods or others. so it uses void keyword.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How do you escape a string?
What is keyset in java?
What is the difference between && and & in java?
Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyall() methods are executed?
Name some OOPS Concepts in Java?
What is a lambda expression ? What's its use ?
Explain method overloading?
Explain the private field modifier?
Can we have more than one package statement in the source file?
Can a function return a function?
How do you invoke a method?
Can we declare the static variables and methods in an abstract class?
Which is dependent variable?
Why we use protected in java?
How can you share data between two thread in Java?