This document discusses different types of errors in programming:
1. It covers syntax errors, runtime errors, logic errors, incorrect operator precedence errors, and threading errors as sources of errors.
2. It provides examples of each type of error, such as division by zero for runtime errors and wrong scoping of variables for logic errors.
3. The document concludes with asking readers to discuss common errors they have encountered and providing a short quiz question about error types.
3. Recap
• In the previous classes, you have studied
about
• Packages
• Interfaces
• Multithreaded programming
3
4. Source of Errors
• There are several types of errors, each with its
own method of detection and repair mechanism
• The basic types of error are
• Syntax errors
• Runtime errors
• Logic errors
• Incorrect operator precedence errors
• Threading errors
4
5. Syntax Errors
• These are errors due to
• Grammar
• Punctuation such as mismatched quotes, missed
commas
• Case-sensitivity issues
• These errors are caught by the javac compiler
5
6. Runtime Errors
• These errors only show up as the program is
executed
• A common example is division by zero
6
7. Logic Errors
• These are basic errors in the programmer's
algorithms or procedural errors
• Diagnosis only comes when incorrect results
occur
• An example is wrong scoping of a variable
7
8. Incorrect Operator Precedence Errors
• These are basic mathematical grouping errors
• The best way to avoid them is with brackets to
force the grouping explicitly
8
9. Threading Errors
• These errors can occur when multiple threads
are programmed
• Common issues are access, deadlock, data
race and synchronization
• These types of errors are very difficult to trace
9
10. Discussion
• List the common errors you encountered
• Spelling and typos
• Brackets or quotes not matched
• Wrong type of bracket. Each has its own use
• Not using the escaper backslash when required
• Un-initialized variables may be referenced
accidentally
• Arrays bounds related
• The type of the variable may be critical
• Casting a variable can cause loss of accuracy
• The scope of a variable can affect its current value
10
11. Summary
• In this class we discussed various types of
errors. They are
• Syntax errors
• Runtime errors
• Logic errors
• Incorrect operator precedence errors
• Threading errors
11
12. Quiz
1. Among the following types of errors which one is
easier to correct
A. Runtime errors
B. Syntax errors
C. Threading errors
D. Logic errors
12