when i search this on google then it show that error means compile time error and exception is runtime error? but i think that it is not that so….
That is generally correct. Although the terms are colloquially interchangeable in many domains.
Error, also known as a compile-time error, is a statement of fact. (Or NOT fact) The compiler is unable to compile the output.
- Technically an error is a state in code that has raised an exception in the compiler’s runtime 🙂
Exception is raised at runtime and is the result of an exceptional combination of values.
Exceptionis raised at runtime, we can generally write code to catch and handle or workaround an exception within your script or code. An
Errorprevents the code from being compiled and thus executed at all, so our only option is to modify the code to resolve an
A compiler may perform syntax and sometimes type checking to ensure that the code follows a set of pre-determined rules and can be compiled into executable statements, but it is not until invalid values are passed into those statements that an Exception can occur, that is harder for a compiler to do and so is generally only detected at Runtime.
Some advanced or specialised compilers may perform checks against common values and as a programer you can write unit tests to try and pre-emptively detect exceptions before releasing your code.
Answered By – Chris Schaller
Answer Checked By – Timothy Miller (BugsFixing Admin)