Why do we use public static with the main function in Java?

Answer Posted / rana

As we know public means we can access the method from
anywhere.Coming to static:- main() is a static method
therefore it implies that there is no need of creating
Object for that particular class to call this method.So
that when ever u run the program the Jvm will search for
main() in the class even there r no class objects created
for this class.

Is This Answer Correct ?    20 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you convert an int to a string in java?

539


How can constructor chaining be done using this keyword?

585


What is replaceall in java?

541


explain copyonwritearraylist and when do we use copyonwritearraylist?

537


How to perform selection sort in java?

580






What is hashmap and map?

549


What is the difference between a constructor and a method?

562


Is char a method in java?

510


What is an infinite loop in java? Explain with an example.

585


In a program, initializing an array of 100 KB is throwing an out of memory exception while there is 100 MB of memory available. Why?

569


What does ide stand for?

512


Can you add null to a list java?

581


Is hashmap thread safe?

553


What are the rules for variable declaration?

496


How can you add and remove nodes in jtree?

610