Chapter 12 - Inheritance and exceptions. In this chapter we will: show how to organize predefined classes using Java packages, how access to methods and variables is controlled, discuss the use of class inheritance to refine and extend classes, refine our presentation on Java interfaces as a means of specifying object behavior, show how programmer-defined exceptions are created, thrown and caught. | Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by . Kamin, D. Mickunas, E. Reingold Chapter Preview In this chapter we will: show how to organize predefined classes using Java packages how access to methods and variables is controlled discuss the use of class inheritance to refine and extend classes refine our presentation on Java interfaces as a means of specifying object behavior show how programmer-defined exceptions are created, thrown and caught Java Packages Application programmer interface (API) All classes provided to programmers along with the Java compiler (. Math or MouseEvent) Java expects to find these classes in separate directories or folders The classes stored in each directory form a package The package names are formed by concatenating the directory names starting from a particular root directory Some Predefined Java Packages Package Name Contents Classes for implementing applets Classes for graphics, windows, and GUI’s Classes supporting AWT event handling Classes for image handling Interface definitions s for platform independent graphical user interfaces (GUI’s) Classes for input and output Basic language classes like Math (always available in any Java program) Classes for networking Useful auxiliary classes like Date Package Component Names Using a fully qualified component name x = (3); Using an import statement // to allow unqualified references to // all package classes import .*; // to allow unqualified references to // a particular package class import ; Import Examples This code d = new (); p = new (1,2); b = new (); Can be abbreviated import ; Import .*; Date d = new Date(); Point p = new | Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by . Kamin, D. Mickunas, E. Reingold Chapter Preview In this chapter we will: show how to organize predefined classes using Java packages how access to methods and variables is controlled discuss the use of class inheritance to refine and extend classes refine our presentation on Java interfaces as a means of specifying object behavior show how programmer-defined exceptions are created, thrown and caught Java Packages Application programmer interface (API) All classes provided to programmers along with the Java compiler (. Math or MouseEvent) Java expects to find these classes in separate directories or folders The classes stored in each directory form a package The package names are formed by concatenating the directory names starting from a particular root directory Some Predefined Java Packages Package Name Contents Classes for .