When the following java code is executed in eclipse, it gives the correct output (i.e. prints \'Class B\'), but according to java specification, the code cannot be compiled (sin
Actually, eclipse tries to compile the class and its not able to compile due to build errors, when you simply run those files it executed the previously compiled class, that were successfully compiled earlier (eclipse tries to compile and build the files on every save as per generic settings).
in order to resolve you can try clean the project before running, while in case of javac, it simply compiles ,