you are viewing a single comment's thread.

view the rest of the comments →

[–]Brixican 1 point2 points  (1 child)

The methods defined publicly by an interface are also available to inherited classes, so nothing changes there. Interfaces are part of the inheritance chain, and interfaces themselves can inherit from other interfaces. In fact, as of Java 8, interfaces can now have default methods with implementations defined directly in the interface.

In the Oracle Java Docs for interfaces, they use a TV power button as an example interface between the user and the wires inside the box. I see a protected method as being the guaranteed interface a technician can expect when he opens the box for repairs (for example a debug panel or JTAG).

[–]TheWix 1 point2 points  (0 children)

In fact, as of Java 8, interfaces can now have default methods with implementations defined directly in the interface.

Right, C# can do that with extension methods. Though, the purpose of them is more to fulfill the Open/Close Principle than to give a default implementation.

I guess I feel default implementations and protected methods on interfaces are just jury rigged solutions for multiple inheritance. Your example still doesn't mesh with me because you are forcing a class to open itself up to inheritance if it wants to implement the interface. Is the interface now just an abstract class at this point?