Here are the three main classes of computer coding errors you’re likely to run into:
1. Logical Errors
We will divide our errors into three classes: logical, syntax, and semantic. But be aware that these same classes can be either static (compile-time) or dynamic (run-time) in nature.
Logical errors are the hardest of all error types to detect. They do not cause the program to crash or simply not work at all, they cause it to “misbehave” in some way, rendering the wrong output of some kind. One example of a logic error is a null reference. Null reference errors are responsible for a huge chunk of application bugs, and they are usually very simple mistakes involving missing or wrong “computer logic.” It may be a property/field is null, a condition has prevented an object from being created, or a local variable field is declared but not initialized.
Logical errors “make sense” as to the computer language itself, but they simply don’t fit into the program correctly.
2. Syntax Errors
Syntax errors in computer programming differ from logical errors in that they don’t follow a correct sequence in the computer language.
With compiled languages, you will run into any syntax errors at compile-time, and they will have to be corrected before the program can run. For interpreted languages, a syntax error would pop up during the run time, and your error message might not even specify it’s a syntax problem. However, in both cases, the compiler/interpreter will give you the location of the syntax error, which makes it rather easy to find/fix.
In general, syntax errors are smaller, even single-digit, errors; while logic errors can involve larger sections of code and the general flow of the code. Some examples of syntax errors would be missing semicolons at a line’s end and an extra/missing bracket at end of a function.
3. Semantic Errors
Semantic errors are improper uses of “program statements.” Though different definitions of semantic error exist, we are saying here that logic errors produce wrong data while semantic errors produce nothing meaningful at all.
For more interview questions [advertising link deleted by Mentors]