Monthly Archives: January 2024

Interface Evolution Augmenting an existing interface with an abstract method will break all classes that implement this interface, as they will no longer implement the old interface. These classes will need to be modified and recompiled in order to work with the augmented interface. Augmenting an existing interface with a default method does not pose this problem. Classes that implement the old interface will work with the augmented interface without modifying or recompiling them. Thus interfaces can evolve without affecting classes that worked with the old interface. This is also true for static methods (p. 251) added to existing interfaces. Example 5.13 Inheriting Method Implementations from Supertypes Click here to view code image // File: MultipleInheritance2.javaclass Slogan {  public void printSlogan() {                        // (1) Concrete method    System.out.println(“Superclass wins!”);  }}//_______________________________________________________________________________interface ISlogan {  default void printSlogan() {                       // (2) Default method    System.out.println(“Superinterface wins!”);  }}//_______________________________________________________________________________class MySlogan extends Slogan implements ISlogan { } //…

Read more

1/1