COMP 213. Advanced Object-oriented Programming. Lecture 17. Exceptions

Similar documents
CS 3 Introduction to Software Engineering. 3: Exceptions

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

ITI Introduction to Computing II

ITI Introduction to Computing II

COMP1008 Exceptions. Runtime Error

About This Lecture. Outline. Handling Unusual Situations. Reacting to errors. Exceptions

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University

BBM 102 Introduction to Programming II Spring Exceptions

Object Oriented Programming

National University. Faculty of Computer Since and Technology Object Oriented Programming

C16b: Exception Handling

Topic 6: Exceptions. Exceptions are a Java mechanism for dealing with errors & unusual situations

More on Exception Handling

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 7

More on Exception Handling

Errors and Exceptions

Exceptions, try - catch - finally, throws keyword. JAVA Standard Edition

Introduction to Computation and Problem Solving. Class 25: Error Handling in Java. Prof. Steven R. Lerman and Dr. V. Judson Harward.

JAC444 - Lecture 4. Segment 1 - Exception. Jordan Anastasiade Java Programming Language Course

Exceptions. Examples of code which shows the syntax and all that

Programming - 2. Common Errors

BBM 102 Introduction to Programming II Spring 2017

Fundamentals of Object Oriented Programming

ECE 122. Engineering Problem Solving with Java

For more details on SUN Certifications, visit

PIC 20A Exceptions. Ernest Ryu UCLA Mathematics. Last edited: November 27, 2017

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

Chapter 14. Exception Handling and Event Handling ISBN

Program Correctness and Efficiency. Chapter 2

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

A Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1

this keyword (1). this with constructor (2). cisc3120 design and implementation of software applications I spring 2015 lecture # I.

CS112 Lecture: Exceptions. Objectives: 1. Introduce the concepts of program robustness and reliability 2. Introduce exceptions

Lecture 19 Programming Exceptions CSE11 Fall 2013

CS Programming I: Exceptions

CSC207H: Software Design. Exceptions. CSC207 Winter 2018

Exceptions. CSE 142, Summer 2002 Computer Programming 1.

Exceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1.

The University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003

What are Exceptions?

Assertions and Exceptions Lecture 11 Fall 2005

Writing your own Exceptions. How to extend Exception

Exception-Handling Overview

Chapter 13 Exception Handling

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

EXCEPTION HANDLING. Summer 2018

Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11

Data Structures. 02 Exception Handling

Introduction. Exceptions: An OO Way for Handling Errors. Common Runtime Errors. Error Handling. Without Error Handling Example 1

What is the purpose of exceptions and exception handling? Vocabulary: throw/raise and catch/handle Exception propagation Java checked and unchecked

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:

Sri Vidya College of Engineering & Technology Question Bank

CSC Java Programming, Fall Java Data Types and Control Constructs

COMP200 EXCEPTIONS. OOP using Java, based on slides by Shayan Javed

EXCEPTIONS. Objectives. The try and catch Statements. Define exceptions. Use try, catch and finally statements. Describe exception categories

Lecture 14: Exceptions 10:00 AM, Feb 26, 2018

CS159. Nathan Sprague

EXCEPTIONS. Java Programming

Exceptions. Errors and Exceptions. Dealing with exceptions. What to do about errors and exceptions

Lecture 20. Java Exceptional Event Handling. Dr. Martin O Connor CA166

COMP 401 EXCEPTIONS. Instructor: Prasun Dewan

Object Oriented Programming

Correctness and Robustness

Introduction to Computer Science II CS S-22 Exceptions

14. Exception Handling

CS 61B Data Structures and Programming Methodology. July 7, 2008 David Sun

Exceptions Handling Errors using Exceptions

Exceptions in Java

CS Programming I: Exceptions

Exceptions and I/O: sections Introductory Programming. Errors in programs. Exceptions

Introductory Programming Exceptions and I/O: sections

Exception Handling. General idea Checked vs. unchecked exceptions Semantics of... Example from text: DataAnalyzer.

Exception in thread "main" java.lang.arithmeticexception: / by zero at DefaultExceptionHandling.main(DefaultExceptionHandling.

CS S-22 Exceptions 1. Running a web server, don t want one piece of bad data to bring the whole thing down

Exception handling & logging Best Practices. Angelin

Pages and 68 in [JN] conventions for using exceptions in Java. Chapter 8 in [EJ] guidelines for more effective use of exceptions.

CS112 Lecture: Exceptions and Assertions

Title. Java Just in Time. John Latham. February 8, February 8, 2018 Java Just in Time - John Latham Page 1(0/0)

Lecture 14 Summary 3/9/2009. By the end of this lecture, you will be able to differentiate between errors, exceptions, and runtime exceptions.

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Object Oriented Programming. Week 7 Part 1 Exceptions

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003

Programming II (CS300)

COE318 Lecture Notes Week 10 (Nov 7, 2011)

Chapter 12 Exception Handling

Exceptions. Produced by. Algorithms. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology

Introduction to Java. Handout-3a. cs402 - Spring

COMP-202. Exceptions. COMP Exceptions, 2011 Jörg Kienzle and others

Exception Handling: Control. Exception handling is the control of error conditions or other unusual events during the execution of a program.

CS115. Chapter 17 Exception Handling. Prof. Joe X. Zhou Department of Computer Science. To know what is exception and what is exception handling

Programming II (CS300)

Exception Handling. Chapter 11. Outline. Example: The Quotient app What Are Exceptions? Java By Abstraction Chapter 11

Chapter 8. Exception Handling. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

6.Introducing Classes 9. Exceptions

Exceptions - Example. Exceptions - Example

Exception Handling Introduction. Error-Prevention Tip 13.1 OBJECTIVES

Exceptions. Produced by. Introduction to the Java Programming Language. Eamonn de Leastar

COMP 401 EXCEPTIONS. Instructor: Prasun Dewan

Reminder. Topics CSE What Are Exceptions?! Lecture 11 Exception Handling

Transcription:

COMP 213 Advanced Object-oriented Programming Lecture 17 Exceptions

Errors Writing programs is not trivial. Most (large) programs that are written contain errors: in some way, the program doesn t do what it s meant to do. There are three main kinds of error: syntactic errors semantic errors input/resource errors

Syntactic Errors Programming languages are formal languages. This means that there is a formal definition of what is an acceptable text for a program in a given language. For example, Java requires all commands to end with a semicolon ( ; ). The compiler will flag any syntactic errors, and will not produce any executable code unless the program is syntactically correct. Syntactic errors are not serious, as they can be automatically detected.

Semantic Errors Programs do exactly what the source code says they do: unfortunately, this might not be what they re meant to do. This is a semantic error. For example, a program might not provide some required functionality (due to poor design or requirements elicitation). a program might provide incorrect functionality (e.g., errors in rounding up fractions). The issue here is the correctness of the program.

Input/Resource Errors A program might function adequately, but be dependent on factors outside the control of its designers and programmers. For example, it might require user input in a specific format, or it might need to access servers across a network, or it might require a minimum amount of RAM memory on the machine it is running on. If some requirement is not met, the program may fail (not in a disastrous way, one would hope). The issue here is the robustness of the program.

Errors, Failures and Exceptions A semantic coding error (or bug ) might go unnoticed until the error causes some input/resource error (such as accessing an array outside its bounds). In such cases, the Java interpreter will raise an exception. To review exceptions, we ll go through an example of a program that contains a bug, a fatal error that causes the Java interpreter to halt and report the error. Here s the program:

A Buggy Program public static void main(string[] args) { } Prop a, t; a = new Prop(Operators.makeVar("a"), new Prop[0]); t = new Prop(Operators.AND OP, new Prop[]{a}); System.out.println(t.toString()); in class Prop

Line 1 Let s go through the execution of this main()-method. As we ve seen, some methods call other methods, which may in turn call other methods, and so on. The Java interpreter keeps track of where it is by maintaining a method-call stack, which stores all the nested method calls. The first method on this stack is always main() The first line declares two variables of type Prop: Prop a, t; method-call stack main

Line 1 Let s go through the execution of this main()-method. As we ve seen, some methods call other methods, which may in turn call other methods, and so on. The Java interpreter keeps track of where it is by maintaining a method-call stack, which stores all the nested method calls. The first method on this stack is always main() The first line declares two variables of type Prop: Prop a, t; method-call stack main

Line 1 Let s go through the execution of this main()-method. As we ve seen, some methods call other methods, which may in turn call other methods, and so on. The Java interpreter keeps track of where it is by maintaining a method-call stack, which stores all the nested method calls. The first method on this stack is always main() The first line declares two variables of type Prop: Prop a, t; method-call stack main

Line 1 Let s go through the execution of this main()-method. As we ve seen, some methods call other methods, which may in turn call other methods, and so on. The Java interpreter keeps track of where it is by maintaining a method-call stack, which stores all the nested method calls. The first method on this stack is always main() The first line declares two variables of type Prop: Prop a, t; method-call stack main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack makevar main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack Prop[]() main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack main

Line 2 The next command creates an instance of Prop, corresponding to a propositional variable a, and assigns this instance to the Java variable a. Note that parameters to a method are always evaluated before that method is actually called. a = new Prop( Operators.makeVar("a"), new Prop[0]); Once a method is fully evaluated, it is removed from the call stack Array constructor Prop constructor method-call stack Prop() main

Line 3 The next command also creates an instance of Prop, and assigns that instance to the variable t: t = new Prop(Operators.AND OP, new Prop[] {a}); This does not correspond to a well-formed term of propositional logic. method-call stack Prop main

Line 3 The next command also creates an instance of Prop, and assigns that instance to the variable t: t = new Prop(Operators.AND OP, new Prop[] {a}); This does not correspond to a well-formed term of propositional logic. method-call stack Prop main

Line 3 The next command also creates an instance of Prop, and assigns that instance to the variable t: t = new Prop(Operators.AND OP, new Prop[] {a}); This does not correspond to a well-formed term of propositional logic. method-call stack Prop main

The Bug We re representing terms as tree structures. As a tree, this value has a top operator, and, and has just one subtree, the variable a. Of course, the operator and requires two arguments. This might worry us (with good cause), but it doesn t raise any compiler-errors, and the interpreter executes the code just as it should do. Specifically, the Prop constructor is evaluated:

An Ill-Formed Term Prop constructor public Prop (Operator o, Prop[] subs) { op = o; operands = subs; } So the instance stored in t has field t.op storing AND OP, and field t.operands storing an array with one element, the Prop corresponding to the variable a.

The remaining line in the main()-method should print a string to standard output: System.out.println(t.toString()); Before the call to println() can do anything, its argument must be evaluated: t.tostring() method-call stack tostring() main

The remaining line in the main()-method should print a string to standard output: System.out.println(t.toString()); Before the call to println() can do anything, its argument must be evaluated: t.tostring() method-call stack tostring() main

Prop.toString() public String tostring() { return tostring(operators.max PREC); } The argument is evaluated (to 48), and then tostring(int) is called. The result of this call is the value that will be returned (to println()). method-call stack tostring(int) tostring() main

Prop.toString() public String tostring() { return tostring(operators.max PREC); } The argument is evaluated (to 48), and then tostring(int) is called. The result of this call is the value that will be returned (to println()). method-call stack tostring(int) tostring() main

Prop.toString() public String tostring() { return tostring(operators.max PREC); } The argument is evaluated (to 48), and then tostring(int) is called. The result of this call is the value that will be returned (to println()). method-call stack tostring(int) tostring() main

Prop.toString() public String tostring() { return tostring(operators.max PREC); } The argument is evaluated (to 48), and then tostring(int) is called. The result of this call is the value that will be returned (to println()). method-call stack tostring(int) tostring() main

Prop.toString(int) Recall: prec is 48; t.op is AND OP; t.operands is an array with one element. public String tostring(int prec) { return op.tostring(operands, prec); } method-call stack tostring( Prop[], int) tostring(int) tostring() main

Prop.toString(int) Recall: prec is 48; t.op is AND OP; t.operands is an array with one element. public String tostring(int prec) { return op.tostring(operands, prec); } method-call stack tostring( Prop[], int) tostring(int) tostring() main

Prop.toString(int) The value returned from the call op.tostring(operands, prec); is the value which will be returned to tostring(), which will return it to println(). Since t.op is AND OP, the method that is called here is the method in the anonymous class in the declaration of AND OP:

AND OP.toString(Prop[],int) public String tostring(prop[] args, int prec) { String s = args[0].tostring(getprecedence()) + " and " + args[1].tostring(getprecedence()); if (prec < AND OP PREC) s = "(" + s + ")"; return s; } No problem with args[0].tostring() Recall that args is t.operands, which has only one element....

AND OP.toString(Prop[],int) public String tostring(prop[] args, int prec) { String s = args[0].tostring(getprecedence()) + " and " + args[1].tostring(getprecedence()); if (prec < AND OP PREC) s = "(" + s + ")"; return s; } No problem with args[0].tostring() Recall that args is t.operands, which has only one element....

AND OP.toString(Prop[],int) public String tostring(prop[] args, int prec) { String s = args[0].tostring(getprecedence()) + " and " + args[1].tostring(getprecedence()); if (prec < AND OP PREC) s = "(" + s + ")"; return s; } No problem with args[0].tostring() Recall that args is t.operands, which has only one element....

The Resource Error When the interpreter attempts to evaluate args[1].tostring(and OP PREC) it attempts to get a reference to the second Prop in the array args, i.e., t.operands[1]. But this array only has one element, so args[1] is out of bounds. In such cases, Java throws an Exception:

The Resource Error When the interpreter attempts to evaluate args[1].tostring(and OP PREC) it attempts to get a reference to the second Prop in the array args, i.e., t.operands[1]. But this array only has one element, so args[1] is out of bounds. In such cases, Java throws an Exception:

ArrayIndexOutOfBoundsException The following appears on standard error output (usually standard output): Exception in thread "main" java.lang.arrayindexoutofboundsexception at Operators$3.toString(Operators.java:164) at Prop.toString(Prop.java:66) at Prop.toString(Prop.java:55) at Prop.main(Prop.java:90) This information is called the stack trace, and gives the state of the method-call stack at the point when the Exception was thrown (and gives useful line numbers in the source files).

ArrayIndexOutOfBoundsException The following appears on standard error output (usually standard output): Exception in thread "main" java.lang.arrayindexoutofboundsexception at Operators$3.toString(Operators.java:164) at Prop.toString(Prop.java:66) at Prop.toString(Prop.java:55) at Prop.main(Prop.java:90) This information is called the stack trace, and gives the state of the method-call stack at the point when the Exception was thrown (and gives useful line numbers in the source files).

Error-Recovery Note that the exception that is thrown can be caught at any point in the stack trace: this is called error-recovery. In Java, methods are caught in try-catch clauses: try { // code that can raise an exception } catch (Exception e) { } // recovery code A program is robust if it recovers from unexpected errors ( fails gracefully ). Note: unexpected errors means resource errors beyond the programmer s control and this doesn t apply in this example (it s just a programmer s bug)

Error-Recovery Note that the exception that is thrown can be caught at any point in the stack trace: this is called error-recovery. In Java, methods are caught in try-catch clauses: try { // code that can raise an exception } catch (Exception e) { } // recovery code A program is robust if it recovers from unexpected errors ( fails gracefully ). Note: unexpected errors means resource errors beyond the programmer s control and this doesn t apply in this example (it s just a programmer s bug)

Error-Recovery Note that the exception that is thrown can be caught at any point in the stack trace: this is called error-recovery. In Java, methods are caught in try-catch clauses: try { // code that can raise an exception } catch (Exception e) { } // recovery code A program is robust if it recovers from unexpected errors ( fails gracefully ). Note: unexpected errors means resource errors beyond the programmer s control and this doesn t apply in this example (it s just a programmer s bug)

Catching Exceptions For example, if the tostring() method was: in class Prop public String tostring() { String s; try { s = tostring(max PREC); } catch (Exception e) { s = "the term is not well-formed"; } return s; } Then the output of the main()-method would be: the term is not well-formed terminal output

Catching Exceptions For example, if the tostring() method was: in class Prop public String tostring() { String s; try { s = tostring(max PREC); } catch (Exception e) { s = "the term is not well-formed"; } return s; } Then the output of the main()-method would be: the term is not well-formed terminal output

A Rule of Thumb Generally, a robust (= good) program will, when things go wrong, catch any exceptions and: inform the user (if necessary), and carry on (if possible). Note that this is what the java interpreter does: when an exception is thrown (and not caught), it informs the user by printing to stderr the type of exception (e.g., ArrayIndexOutOfBoundsException), and the stack trace. But note that the term is not well-formed is a much better error message for most users!

A Rule of Thumb Generally, a robust (= good) program will, when things go wrong, catch any exceptions and: inform the user (if necessary), and carry on (if possible). Note that this is what the java interpreter does: when an exception is thrown (and not caught), it informs the user by printing to stderr the type of exception (e.g., ArrayIndexOutOfBoundsException), and the stack trace. But note that the term is not well-formed is a much better error message for most users!

A Rule of Thumb Generally, a robust (= good) program will, when things go wrong, catch any exceptions and: inform the user (if necessary), and carry on (if possible). Note that this is what the java interpreter does: when an exception is thrown (and not caught), it informs the user by printing to stderr the type of exception (e.g., ArrayIndexOutOfBoundsException), and the stack trace. But note that the term is not well-formed is a much better error message for most users!

The Exception Zoo java.lang.exception +-java.lang.runtimeexception +-java.lang.indexoutofboundsexception +-java.lang.arrayindexoutofboundsexception +-java.lang.nullpointerexception...

Subclasses Try-catch blocks can be used to catch specific subclasses of Exception. For example, the method public static int parseint(string s) in class java.lang.integer attempts to read a string as an integer. int i = Integer.parseInt("27"); will set i to 27. If the String parameter cannot be parsed as an integer, then the method throws a NumberFormatException.

Catching NumberFormatException String s = "3w"; try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { } System.err.println("not a valid integer: " + nfe.getmessage()); Catching the specific subclass of RuntimeException The Exception class has some useful methods: getmessage() will print here For input string: 3w

Catching NumberFormatException String s = "3w"; try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { } System.err.println("not a valid integer: " + nfe.getmessage()); Catching the specific subclass of RuntimeException The Exception class has some useful methods: getmessage() will print here For input string: 3w

Catching NumberFormatException String s = "3w"; try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { } System.err.println("not a valid integer: " + nfe.getmessage()); Catching the specific subclass of RuntimeException The Exception class has some useful methods: getmessage() will print here For input string: 3w

Different types of Exception can be caught separately: try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { System.err.println(...); } catch (NullPointerException npe) { } System.err.println("s not instantiated"); nfe.printstacktrace(); If s is, e.g., "doh", the first catch-block will be executed; if s is null, the second catch-block will be executed.

Different types of Exception can be caught separately: try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { System.err.println(...); } catch (NullPointerException npe) { } System.err.println("s not instantiated"); nfe.printstacktrace(); If s is, e.g., "doh", the first catch-block will be executed; if s is null, the second catch-block will be executed.

Different types of Exception can be caught separately: try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { System.err.println(...); } catch (NullPointerException npe) { } System.err.println("s not instantiated"); nfe.printstacktrace(); If s is, e.g., "doh", the first catch-block will be executed; if s is null, the second catch-block will be executed.

When an exception is thrown, the Java interpreter looks through the list of catch-blocks, and executes the first one that applies to the particular exception. Superclasses should therefore be below subclasses: try { int i = Integer.parseInt(s); } catch (NumberFormatException nfe) { System.err.println(...); } catch (NullPointerException npe) { System.err.println("s not instantiated"); } catch (RunTimeException re) { } System.err.println("something else...");

Default Actions After some number (including zero!) of catch-blocks, you can include a finally-block, which will be executed whether or not an exception is thrown. // some code to open a file try { // to write to the file } catch (IOException ioe) { // oops } finally { } // close the file

RuntimeException The RuntimeException class is for exceptions that can occur in the normal running of the Java Virtual Machine. (That quote is from the API!) They generally arise from semantic coding errors (programmers bugs). Exceptions can be thrown and caught. As we ll see, uncaught errors generally need to be advertised through throws-clauses in method heads. This has the advantage that users of methods that might throw exceptions know this, and therefore know that they should either pass those exceptions on (and advertise this), or catch those exceptions

RuntimeException The RuntimeException class is for exceptions that can occur in the normal running of the Java Virtual Machine. (That quote is from the API!) They generally arise from semantic coding errors (programmers bugs). Exceptions can be thrown and caught. As we ll see, uncaught errors generally need to be advertised through throws-clauses in method heads. This has the advantage that users of methods that might throw exceptions know this, and therefore know that they should either pass those exceptions on (and advertise this), or catch those exceptions

RuntimeException However, subclasses of RuntimeException do not need to be advertised. Advertising them would be of no benefit, as they almost always arise through oversight or carelessness. For this reason, RuntimeException and its subclasses are called unchecked exceptions.

And Finally... Bugs are a fact of life, but can be contained: top-level code public static void main(string[] args) { } try { // code here } catch (Exception e) { } System.out.println("An error ocurred. " + "Please submit a report...");

Summary Types of errors Exceptions method-call stack stack trace try-catch Next: Checked Exceptions