Exception handling.41

309 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
309
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Exception handling.41

  1. 1. Exception Handling, I/O Streams, and Applets 1
  2. 2. ObjectivesOn completion of this period, you would be able to know:• The sources of errors 2
  3. 3. Recap• In the previous classes, you have studied about • Packages • Interfaces • Multithreaded programming 3
  4. 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. 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. 6. Runtime Errors• These errors only show up as the program is executed• A common example is division by zero 6
  7. 7. Logic Errors• These are basic errors in the programmers algorithms or procedural errors• Diagnosis only comes when incorrect results occur• An example is wrong scoping of a variable 7
  8. 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. 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. 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. 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. 12. Quiz1. 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
  13. 13. Frequently Asked Questions1. Explain about various sources of errors 13

×