This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I was solving a 1.4 mock exam. It had private main method and print statement in it. The answer provided is that the print statement will be executed. I tried this on my machine but found that I was getting a runtime message that main method is not public.
There is only one signature of main that the JVM looks for to launch an application, i.e. void main(String args) and that is must be public and static. However you,re free to declare another method named main in your code, apart from the main() method required by the JVM, but with a different signature.
As you can see, the main issue is a known problem with a bug report opened against it. However, Sun has closed the bug report and the problem will NOT be fixed, "The runtime allows call to private methods, because of reflection. Fixing it will cause potential troubles."
So there you have it.
However, be careful while taking the certification exam. Last time that I checked, the proper answer to "How do you define a main?" remains: "The method main must be declared public, static, and void." Reality and the correct answer seem to disagree.