Originally posted by kaushik banerjee:
Hi fellow ranchers,
I have a problem with a concept which is getting a few wrong answers in the Mocks . I will be extremely grateful if any of can take the trouble to clear the same . It is:-
There are questions with options that the a) code will not compile at runtime : b) the code will give runtime errors . Now when I know that the code is erroneous & will not work , how do I differentiate between these 2 options, that is what sort of errors are caught at compile time & what sort of errors is the responsibility of the runtime environment(JVM) . Please can someone explain .
Thanks in advance.
Regards,
Kaushik
Hello Kaushik,
Compile errors have to do mostly with syntactical and rules of the language. In addition to that, if the complier is smart, it will also catch obvious errors in program logic or potential boundary and mathematical violations. Compile errors will prevent you from generating class files or executable units.
Once your program is free from compilation errors, it might or might not generate any error. An error caught by JVM during program execution is a runtime error.
Regards,
Lam