If we declare the main method as private instead of public it will execute or not
If we declare the main method as private instead of public it will execute or not
No error on complile time. But you got the run time error like "main method is not public".
--------------------
suresh
No...because,execution will start from main itself....it needs to accessable by anywhere....
hi ramesh,
Are you trying for this one? Don't you get error at run time?
-------------------
suresh
No U cant declare main method as Private.
During runtime it gives no such method error.
hi ,
In run time,jvm checks main method with this convention(public static void main(String args[]) )
if you dont define this method as actually defined, JVM shows run time error as no such method.it wont execute any statement of any other main method.
One can declare the main method as private, but a main method with private access specifier will not be treated by the java runtime, as entry point of the program.