WDD_lec_07 - Web Design & Development Lecture 7 Intro to...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 7
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Intro to Exceptions
Background image of page 2
Types of Programming Errors Three types of error: Syntax Errors – arise because the rules of the language are not followed. Runtime Errors – arise because the program tries to perform an operation that is impossible to carry out. Logic Errors – arise because the program does perform the way it was intended to. Syntax errors are caught by the compiler, and fixed before the program is run. Logic Errors are detected by testing, and are fixed through debugging. Runtime Errors cause Exceptions and may be handled at runtime.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Exceptions An exception is an event that describes an unusual or erroneous situation at runtime. Exceptions are wrapped up as objects A program can deal with an exception in one of three ways: i gnore it handle it where it occurs handle it an another place in the program An error is also represented as an object in Java, but usually represents an unrecoverable situation and should not be caught
Background image of page 4
Why Use Exceptions? Uses of exception handling Process exceptions from program components Handle exceptions in a uniform manner in large projects Remove error-handling code from “main line” of execution What if Exception is not handled? Might terminate program execution
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Exceptions Types Two Types Unchecked Subclasses of RuntimeException and Error. Does not require explicit handling Run-time errors are internal to your program, so you can get rid of them by debugging your code For example, null pointer exception; index out of bounds exception; division by zero exception; . ..
Background image of page 6
Exceptions Types Two Types Checked Must be caught or declared in a throws clause Compile will issue an error if not handled appropriately Subclasses of Exception other than subclasses of RuntimeException. Other arrive from external factors, and cannot be solved by debugging Communication from an external resource – e.g. a file server or database
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Throwable Exception Error IOException ArrayIndexOutOfBoundsException InputMismatchException NullPointerException Runtime Exception AWTError ThreadDeath ClassCastException OutOf MemoryError ArithmeticException Checked Exceptions UnChecked Exceptions Error
Background image of page 8
How are Java Exceptions Handled
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/01/2010 for the course CS CS506 taught by Professor mr. umair javed during the Spring '10 term at Virtual University of Pakistan.

Page1 / 37

WDD_lec_07 - Web Design & Development Lecture 7 Intro to...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online