0

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?

2
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by jwenting
0

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
}
0

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

0

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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.