I started over with reading my certification book, and I'm now on page 113. It says that an interface can extend one or more other interfaces.....I thought you could only extend one thing, or do they mean the interfaces that the extended interface extended?

Recommended Answers

All 3 Replies

Classes can extend only 1 other class (as well as implementing any number of interfaces).
Interfaces can extend any number of other interfaces (but can't implement anything obviously).

So you can have something like

public interface MyInterface extends List, Serializable, Comparable {
//... method declarations
}

Is there a reason they chose to let it extend more than one, instead of letting it implement and not extend?

an interface can't implement anything. If it could you'd have an abstract class.
Something like

public interface MyInterface extends Serializable, List implements Comparable {
  public int compareTo(Object o) {
    // implementation code
  }

  public void myMethod();
}

isn't an interface is...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.