This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by NateshK Kurup: it works fine bcz its the earlier code which is getting executed. Rename the second class, it will compile but wont execute.
No. There is a possibility that it might execute even after renaming!
Originally posted by shandilya popuru: so even if main method isn`t decld public it works fine plz explain me what is the diff
The problem here is with the JVM version you are using. With the earlier JVMs, it is mandatory that you have to specify the main() method as public. But later, for some reasons, some versions allowed (1.2.2 & 1.3 I think) you to have non-public main method. If you try the same code with version 1.4, you will get an Runtime error saying "Main method is not public". Don't know what is the case with 1.5. Anybody who has 1.5 installed can throw some light.