What happens when a main method is declared as private?

Answer Posted / chinmay

If main method declared as private then at compilation no problem but at run time it shows an error that main method should be public...
because we access the main() method out side from class if it is private then it cannot be accessible...
that's why we have to write public in main method signature...

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is implicit object in java?

543


How do you define a method?

507


How to provide security in java

1798


Explain about the main() method in java?

564


Is set ordered?

535






How would you use Bubble Sort to sort the number of elements?

576


What is the difference between this() and super() in java?

533


How many types of assembly languages are there?

518


Can sleep() method causes another thread to sleep?

560


Tell me are there implementations for sorting and searching in the java libarary?

592


What about main thread in java?

642


Explain importance of inheritance in java?

600


If system.exit (0); is written at the end of the try block, will the finally block still execute?

613


What is garbage collector?

616


What is a numeric format?

555