What happens when a main method is declared as private?

Answer Posted / pawan

vani, varsha is correct , the 'private main method' is as
good as any member method your class can have (note that
main is not a key word in java) , it can be only used inside
the class in which it is defined.

It is clearly mentioned in the specifications that the
executing class should contain a 'public static void method'
as a point of execution otherwise execution will fail
complaining ABOUT THE METHOD WHICH I MENTIONED ABOVE.

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can interface be private in java?

540


What is an immutable object? How do you create one in java?

595


What is a finally block?

556


Explain abstract class in java?

552


What is an inner class in java?

519






What is the difference between the font and fontmetrics classes in java programming?

493


Is a boolean variable?

513


What is the difference between variable & constant?

536


String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?

539


How do you create a sop?

524


Can a class have multiple subclasses?

581


How do you check whether the list is empty or not in java?

507


What is preparedstatement in java?

553


Explain all java features with real time examples

1204


Why do we need singleton?

533