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


Please Help Members By Posting Answers For Below Questions

Do we have pointers in java?

540


What is class level lock ?

618


What do you mean by aggregation?

582


Convert Binary tree to linked list.

602


What is keyword auto for?

648






What does flag mean in java?

546


What is final keyword?

654


What are the six ways to use this keyword?

620


When will you define a method as static in Java?

580


Can we create constructor in abstract class ?

592


What is the instance of an object?

563


Can you pass by reference in java?

531


Explain importance of inheritance in java?

613


Can a method be overloaded based on different return type but same argument type?

554


What is method in research paper?

583