Lecture Java: Chapter 11

Lecture Java: Chapter 11 (Exception) focuses on the purpose of exceptions, exception messages, the try-catch statement, propagating exceptions, the exception class hierarchy. | Copyright © 2012 Pearson Education, Inc. Chapter 11 Exception Java Software Solutions Foundations of Program Design Seventh Edition John Lewis William Loftus Exceptions Exception handling is an important aspect of object-oriented design Chapter 11 focuses on: the purpose of exceptions exception messages the try-catch statement propagating exceptions the exception class hierarchy 10-2 Outline 10-3 Exception Handling The try-catch Statement Exception Classes I/O Exceptions Exceptions An exception is an object that describes an unusual or erroneous situation Exceptions are thrown by a program, and may be caught and handled by another part of the program A program can be separated into a normal execution flow and an exception execution flow An error is also represented as an object in Java, but usually represents a unrecoverable situation and should not be caught 10-4 Exception Handling Java has a predefined set of exceptions and errors that can occur during execution A program can deal . | Copyright © 2012 Pearson Education, Inc. Chapter 11 Exception Java Software Solutions Foundations of Program Design Seventh Edition John Lewis William Loftus Exceptions Exception handling is an important aspect of object-oriented design Chapter 11 focuses on: the purpose of exceptions exception messages the try-catch statement propagating exceptions the exception class hierarchy 10-2 Outline 10-3 Exception Handling The try-catch Statement Exception Classes I/O Exceptions Exceptions An exception is an object that describes an unusual or erroneous situation Exceptions are thrown by a program, and may be caught and handled by another part of the program A program can be separated into a normal execution flow and an exception execution flow An error is also represented as an object in Java, but usually represents a unrecoverable situation and should not be caught 10-4 Exception Handling Java has a predefined set of exceptions and errors that can occur during execution A program can deal with an exception in one of three ways: ignore it handle it where it occurs handle it an another place in the program The manner in which an exception is processed is an important design consideration 10-5 Exception Handling If an exception is ignored by the program, the program will terminate abnormally and produce an appropriate message The message includes a call stack trace that: indicates the line on which the exception occurred shows the method call trail that lead to the attempted execution of the offending line See (page 533) 10-6 Outline 10-7 Exception Handling The try-catch Statement Exception Classes I/O Exceptions The try Statement To handle an exception in a program, the line that throws the exception is executed within a try block A try block is followed by one or more catch clauses Each catch clause has an associated exception type and is called an exception handler When an exception occurs, processing continues at the first catch clause that matches the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.