【正文】
the specified semantics, then software written for classes that implement the interface may not work correctly 1313 Copyright 169。 2021 Pearson AddisonWesley. All rights reserved. Abstract Classes Implementing Interfaces ? Abstract classes may implement one or more interfaces – Any method headings given in the interface that are not given definitions are made into abstract methods ? A concrete class must give definitions for all the method headings given in the abstract class and the interface 139 Copyright 169。 2021 Pearson AddisonWesley. All rights reserved. The Ordered Interface 135 Copyright 169。 2021 Pearson AddisonWesley. All rights reserved. Interfaces ? An interface is something like an extreme case of an abstract class – However, an interface is not a class – It is a type that can be satisfied by any class that implements the interface ? The syntax for defining an interface is similar to that of defining a class – Except the word interface is used in place of class ? An interface specifies a set of methods that any class that implements the interface must have – It contains method headings and constant definitions only – It contains no instance variables nor any plete method definitions 132 Copyright 169。 2021 Pearson AddisonWesley. All rights reserved. Interfaces ? An interface serves a function similar to a base class, though it is not a base class – Some languages allow one class to be derived from two or more different base classes – This multiple inheritance is not allowed in Java – Instead, Java39。 2021 Pearson AddisonWesley. All rights reserved. Interfaces ? To implement an interface, a concrete class must do two things: 1. It must include the phrase implements Interface_Name at the start of the class definition – If more than one interface is implemented, each is listed, separated by mas 2. The class must implement all the method headings listed in the definition(s) of the interface(s) ? Note the use of Object as the parameter type in the following examples 136 Copyright 169。 2021 Pearson AddisonWesley. All rights reserved. An Abstract Class Implementing an Interface 1310 Copyright 169。 2021 Pearson AddisonWesley. All rights reserved. The Comparable Interface ? Chapter 6 discussed the Selection Sort algorithm, and examined a method for sorting a partia