Java Reference
In-Depth Information
To Extend an Abstract Class
1. In the TextPad window, click the New Document button on the
Standard toolbar.
2. Click File on the menu bar and then click Save As on the File menu.
When the Save As dialog box is displayed, click the Save in box arrow
and then click 3 1 / 2 Floppy (A:) in the Save in list.
3. Double-click the Chapter10 folder or a location specified by your instructor.
4. Type PasswordExpiredException in the File name text box and then
click Java (*.java) in the Save as type list. Click the Save button in the
Save As dialog box.
5. Enter lines 1 through 26 as shown in Figure 10-8 on the previous page.
In the comments, insert your own name as programmer and enter the
current date.
TextPad displays code for the initial comments, PasswordExpiredException
class header, constructors, and usage() method in the coding window
(Figure 10-10). The PasswordExpiredException class inherits from
PasswordException by using the keyword, extends, and implements the
abstract method, usage(), inherited from PasswordException.
class inherits from
PasswordException class
implements inherited
abstract method
String message returned by
PasswordExpiredException
usage() method
FIGURE 10-10
6. Save and compile the PasswordExpiredException class.
7. Repeat steps 1 through 6 for the class, PasswordUsedException. In step 5,
enter lines 1 through 25 as shown in Figure 10-9 on the previous page.
TextPad displays code for the initial comments, PasswordUsedException
class header, constructors, and usage() method in the coding window
(Figure 10-11). The PasswordUsedException class inherits from
PasswordException by using the keyword, extends, and implements the
abstract method, usage(), inherited from PasswordException. TextPad
displays the new Java source files in the document selector window.
 
Search WWH ::




Custom Search