Java Reference
In-Depth Information
Figure 10-19 displays the code for the PasswordInternalException class.
The final keyword in line 11 declares the class as a final class. Lines 18 through
23 include a usage() method. Because this class extends the abstract class,
PasswordException, it is required to override the method, usage(). The following
step enters code to create a final class.
To Create a Final Class
1. Create and then save a new document in the Chapter10 folder,
or a location specified by your instructor, typing
PasswordInternalException as the file name and selecting
Java (*.java) as the file type. Enter lines 1 through 23 as shown
in Figure 10-19. In the comments, insert your own name as
programmer and enter the current date. Save and compile the
PasswordInternalException class.
TextPad displays code for the initial comments, class header, constructor,
and the method, usage(), in the coding window (Figure 10-20).
class inherits from
PasswordException class
implements inherited
abstract method
String message returned by
PasswordInternalException
usage() method
FIGURE 10-20
All of the classes in the PasswordException hierarchy are complete and ready
for use. These classes were designed for use by the Password class, which now
must be modified accordingly.
 
Search WWH ::




Custom Search