Java Reference
In-Depth Information
Display 13.3
An Abstract Class Implementing an Interface
1 public abstract class MyAbstractClass implements Ordered
2 {
3 private int number;
4 private char grade;
5
6 public boolean precedes(Object other)
7 {
8 if (other == null )
9 return false ;
10 else if (!(other instanceof HourlyEmployee))
11 return false ;
12 else
13 {
14 MyAbstractClass otherOfMyAbstractClass =
15 (MyAbstractClass)other;
16
return ( this .number < otherOfMyAbstractClass.number);
17 }
18 }
19
public abstract boolean follows(Object other);
20 }
Display 13.4
Extending an Interface
1 public interface ShowablyOrdered extends Ordered
2 {
3
/**
4
Outputs an object of the class that precedes the calling object.
5
*/
6
public void showOneWhoPrecedes();
7 }
Neither the compiler nor the run-time system
will do anything to ensure that this comment is
satisfied.
A (concrete) class that implements the ShowablyOrdered interface must have a
definition for the method showOneWhoPrecedes and also have definitions for the
methods precedes and follows given in the Ordered interface.
 
 
Search WWH ::




Custom Search