Upload
myrajendra
View
429
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
1
Exception Handling, I/O Streams, and Applets
2
Objectives
On completion of this period, you would be able to know:
• The sources of errors
3
Recap
• In the previous classes, you have studied about • Packages • Interfaces• Multithreaded programming
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
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
6
Runtime Errors
• These errors only show up as the program is executed
• A common example is division by zero
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
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
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
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
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
12
Quiz
1. Among the following types of errors which one is easier to correctA. Runtime errorsB. Syntax errorsC. Threading errorsD. Logic errors
13
Frequently Asked Questions
1. Explain about various sources of errors