Preview

Java Exception Handling

Powerful Essays
Open Document
Open Document
7853 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java Exception Handling
[Page 575]

Part 4: Exception Handling, I/O, and Recursion
The Goddess Chalchihuitlicue, found in the Valley of Mexico, 1300-1500 AD (stone), Aztec / Musée de l'Homme, Paris, France / Bridgeman Art Library

This part introduces the use of exception handling and assertions to make your programs robust and correct, the use of input and output to manage and process a large quantity of binary data, and the use of recursion to write methods for solving inherently recursive problems.
[Page 576]

Prerequisites for Part 4
All the chapters after Chapter 17 are designed to minimize dependencies so that they can be reordered flexibly. Chapter 17, "Exceptions and Assertions," can be covered after Chapter 9, "Inheritance and Polymorphism." Chapter 18, "Binary I/O," is usually covered after Chapter 17. The concept of recursion and how to write simple recursive programs in §§19.1–19.3 can be covered after Chapter 6, "Arrays."

Chapter 17 Exceptions and Assertions Chapter 18 Binary I/O Chapter 19 Recursion
[Page 577]

Chapter 17. Exceptions and Assertions
Mayan God Shel, Mexico. Photographer: Philip Coblentz. Courtesy Brand X Pictures

Objectives
To understand exceptions and exception handling (§§17.2–17.3). To distinguish exception types: Error (fatal) vs. Exception (non-fatal), and checked vs. unchecked (§17.3). To declare exceptions in a method header (§17.4.1). To throw exceptions in a method (§17.4.2). To write a try-catch block to handle exceptions (§17.4.3). To explain how an exception is propagated (§17.4.3). To use the finally clause in a try-catch block (§17.5). To know when to use exceptions (§17.6). To rethrow exceptions in a try-catch block (§17.7). To create chained exceptions (§17.8). (Optional) To declare custom exception classes (§17.9). (Optional) To apply assertions to help ensure program correctness (§17.10).
[Page 578]

17.1. Introduction
Three categories of errors (syntax errors, runtime errors, and logic errors) were introduced in

You May Also Find These Documents Helpful

  • Better Essays

    “So far archeologist have found 139 offerings and more than 9,000 objects, including children’s skeletons, bones of marine fish, turtle shells…masks, musical instruments… and cotton textiles.”22 Archeologist even discovered what appeared to be a “…god of death statue… bathed with large quantities of blood from sacrificed people…”23 A reminder of gory rituals practiced by the Aztecs. What is interesting about some of the more obscure and less exciting items is not the items themselves but where they came from. Objects that were unearthed were found to have come from places such as the Gulf Coast, Guerrero24, and “…the modern states of New Mexico and Arizona.”25 This shows the extensive lengths that the Aztecs travelled for trade. Their power, influence and strength reached far beyond the boundaries of their capital in Tenochtitlan. Many of the more significant offerings and objects found at the temple are reminders of the importance of the two deities of the Templo Mayor to the Aztec people. Every layer of fill contained offerings to the gods, most of which were related to Huitzilopochtli and Tlaloc.26 Leonardo Lopez Lujan and Judy Levin believe that the arrangement of the offerings in the fill “… can tell us how the Aztec people understood the world and what they were trying to say to the gods through their…

    • 1788 Words
    • 8 Pages
    Better Essays
  • Good Essays

    This is our first individual assignment for Programming unit this semester. This assignment was given in December 2013, and submission date is on 10th February 2014.…

    • 1859 Words
    • 8 Pages
    Good Essays
  • Powerful Essays

    Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26 Chapter 27 An Introduction to Hardware, Software, and the Internet An Introduction to Software Development Objects and Classes Algorithms Java Syntax and Style Data Types, Variables, and Arithmetic Boolean Expressions and if-else Statements Iterative Statements: while, for, do–while Implementing Classes and Using Objects Strings Class Hierarchies and Interfaces Arrays…

    • 3908 Words
    • 16 Pages
    Powerful Essays
  • Powerful Essays

    EAS230Syllabus

    • 1748 Words
    • 8 Pages

    An introduction to computer programming with an emphasis on problem solving will be presented. Specific topics include:…

    • 1748 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Huipil Clothing Analysis

    • 1098 Words
    • 5 Pages

    Before the conquest of Mexico by the Spaniards in the 1500s, the life of an indigenous women, from birth to death, was largely occupied with the sole production of weaving garments for herself and her family, as well as ceremonial clothes for use in the temples and for tribute (Cordry 5). The huipil is considered to be one of the most influential aspect of women’s clothing in ancient times, which is still worn today in Guatemalan and Mexican. The present essay seeks to interpret and decipher the meaning of a contemporary huipil blouse displayed at the Penn Museum Collections, by exploring popular designs and patterns found in the ancient Maya and contemporary Maya textile representations.…

    • 1098 Words
    • 5 Pages
    Good Essays
  • Powerful Essays

    Pueblo Maiden Essay

    • 1076 Words
    • 5 Pages

    At the Montclair Art Museum, located in the Rand Gallery of Native American Art, there is a tall statue made of Bronze and Jetulong wood, standing tall behind a glass case, called Pueblo Maiden. The figure is long and lean, and towers over many of the other artifacts in the gallery. The bronze color of the figure is constant throughout the sculpture. The head is small and round. The hairstyle is short and square shaped. It is similar to a women’s “bob” hairstyle with bangs that covers the figures forehead and ears. The surface of sculpture is smooth. The face features two indentations which look like closed eyes and a rectangle shape for the nose but there is no indentation for a mouth. The head of the figure rests on a narrow shaped neck.…

    • 1076 Words
    • 5 Pages
    Powerful Essays
  • Better Essays

    Xochiquetzal Essay

    • 1035 Words
    • 5 Pages

    Miller, Mary Ellen., and Karl A. Taube. The gods and symbols of ancient Mexico and the Maya: An illustrated dictionary of Mesoamerican religion. New York: Thames and Hudson, 1993.…

    • 1035 Words
    • 5 Pages
    Better Essays
  • Good Essays

    Mayan Art Chapter 1 Essay

    • 546 Words
    • 3 Pages

    On page 343, I found a great example of the Mayan art. The art piece is called Lintel 24 from Yaxchilan. This art piece is a sculpture. The sculpture has written symbols on the sides of it. There is a King standing holding a flaming torch. In it as well is his wife kneeling in front of him facing towards him. This is a really interesting sculpture because it has true meaning to the Mayans. The sculpture also has the wife drawing blood from her tongue. She has patterned clothing on. Their clothing is very detailed with textures.…

    • 546 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    concepts of classes, objects, constructors, methods, access control, this keyword, overloading methods and constructors, parameter…

    • 414 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Olmec Cave Essay

    • 634 Words
    • 3 Pages

    The cave of Juxtlahuaca lies east of the capital of Guerrero, Chilpancingo. Carlo Gay and Gillett Griffon, Princeton art…

    • 634 Words
    • 3 Pages
    Good Essays
  • Better Essays

    Female Figure Analysis

    • 1506 Words
    • 7 Pages

    Throughout history the woman figure has been depicted in many ways. One of the most prominent way in which the female figure is seen is as a reference to fertility. Another much more appealing aspect of femininity is its use to represent ferocious deities. This essay will examine the different ways in which the female figure has been depicted by examining four pieces of art. The four pieces I will focus on will be: Female figurine found at Dolni., Innana/Ishtar with Lions and Owls, The Gorgon, Medusa, from the west pediment for the Artemis Temple, and Coatlicue, from Aztec temple precinct at Tenochtitlán.…

    • 1506 Words
    • 7 Pages
    Better Essays
  • Good Essays

    Teotihuacan mural

    • 634 Words
    • 3 Pages

    While the mural gallery at appears to be nothing more than the typical non-Western cultural art and ancient artifacts showcase, the book Feathered Serpents and Flowering Trees discusses the Teotihuacan murals, the history of the murals, and the impact they had on the art world. Again, the artwork fragments from the Teotihuacan Mural Gallery came to the de Young Museum as a surprise bequeathal from Harald Wagner, a Pre-Colombian art collector and San Francisco native. The first segment in Feathered Serpents and Flowering Trees written by Thomas K. Seligman describes the gift as both “unexpected” as well as an “ethical dilemma.” Seligman discussed how the de Young Museum collaborated with the National Museum of Mexico and UNESCO (United Nations Educational, Scientific and Cultural Organization) while dealing with the ethical, legal and museological issues surrounding the enormous, seventy-plus piece gift. Seligman explained how the “Museum’s initial concern was for the safety of [the] very fragile objects” (Seligman 16), and how after the immediate museological concerns of artwork preservation was addressed that the more convoluted issues involving cultural patrimony and the return of Mexican national treasures. The…

    • 634 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Our Fourth Amendment rights prohibit unlawful searches and seizures, but do not state how evidence that is obtained from searches can be used. In 1914 with the case of Weeks vs. United States, the court ruled that illegally obtained evidence can not be used in federal cases. The above sentence is known as the Exclusionary Rule. Our lesson notes explain that the Exclusionary rule states, “that any evidence obtained from an illegal search must be excluded from criminal proceedings on the basis of the Fourth Amendment, as well as the Fifth Amendment's provision against self-incrimination, though more court rulings allow for a “good faith exception” to the Exclusionary Rule (Rio Salado, 2017).”…

    • 225 Words
    • 1 Page
    Satisfactory Essays
  • Powerful Essays

    The Springville Herald Case

    • 5252 Words
    • 22 Pages

    Almost half the errors are accounted for by copy error, typesetting, and wrong position. If we also include ran-in error and velox, almost two-third of the errors are included. We would suggest that reduction of these errors be focused upon if our goal is improvement in the number of errors committed.…

    • 5252 Words
    • 22 Pages
    Powerful Essays
  • Good Essays

    15.3.1 Classes: class diagram; dependencies and inheritances; identification attributes; methods; the control of scope of attributes and methods; inheritance; aggregation; association; polymorphism; pre-defined classes. E.g. class library, downloaded, imported…

    • 742 Words
    • 3 Pages
    Good Essays

Related Topics