TAILIEUCHUNG - Object-Oriented Programming Lecture 6: Exceptions

Object-Oriented Programming Lecture 6: Exceptions What is an exception? Catching and handling exceptions, Specifying the exceptions thrown by a method, How to throw exceptions, Advantages of exceptions. | Object-Oriented Programming Lecture 6: Exceptions Dr. Lê H!ng Ph"#ng -- Department of Mathematics, Mechanics and Informatics, VNUH August 2012 1 Thursday, August 9, 12 Content ✦ What is an exception? ✦ Catching and handling exceptions ✦ Specifying the exceptions thrown by a method ✦ How to throw exceptions ✦ Advantages of exceptions ✦ Exercises 2 Thursday, August 9, 12 What is an exception? ✦ An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions. ✦ When an exception occurs within a method, the method creates an exception object and hands it off to the runtime system. ✦ ✦ The exception object contains information about the error (its type, the state of the program when the error occurred). Creating an exception object and handing it to the runtime system is called throwing an exception. 3 Thursday, August 9, 12 What is an exception? ✦ When an exception is thrown, the runtime system attempts to find something to handle it. ✦ A set of possible “somethings” is the ordered list of methods that had been called to get to the method where the error occurred. ✦ This list of methods is known as call stack. 4 Thursday, August 9, 12 What is an exception? ✦ The runtime system searches the call stack for a method that can handle the exception. ✦ ✦ ✦ The block of code that handles the exception is called exception handler. The type of exception object thrown must match the type that can be handled by the handler. When the handler is found, the runtime passes the exception to the handler. 5 Thursday, August 9, .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.