Java Reference
In-Depth Information
FIGURE 10-16
The following steps enter code to extend the child class,
PasswordInvalidException, to create two additional child classes,
PasswordInvalidFormatException and PasswordSizeException.
To Extend a Child Class
1. Create and then save a new document in the Chapter10
folder, or a location specified by your instructor, typing
PasswordInvalidFormatException as the file name and
selecting Java (*.java) as the file type. Enter lines 1 through 25 as
shown in Figure 10-15 on the previous page. In the comments, insert
your own name as programmer and enter the current date. Save and
compile the PasswordInvalidFormatException class.
TextPad displays code for the initial comments, class header, constructors,
and the method, usage(), in the coding window (Figure 10-17). Note that
this class extends the concrete class, PasswordInvalidException, not the
abstract class, PasswordException. The method, usage(), although not
required, overrides the method defined in the parent class.
 
Search WWH ::




Custom Search