If we can use the default and static methods in the Interface and implement it in other classes, then how can we say that the interface achieve 100% abstraction?
-
2Did you read that in a book/tutorial? If so, can you please quote it in context? – ernest_k Apr 10 '20 at 05:35
-
And see if it refers to a specific version of Java, or provide the publication date if not? – chrylis -cautiouslyoptimistic- Apr 10 '20 at 06:32
-
semi-related: https://stackoverflow.com/questions/46377594/interface-segregation-principle-and-default-methods-in-java-8 – jaco0646 Apr 10 '20 at 13:43
1 Answers
Can we say that the interface achieve 100% abstraction?
I think we can still say that. Or at least we can say that static
and default
in an interface don't make it any harder to achieve 100% abstraction1.
A static
method in an interface is no different to a static
method in a class. In both cases, the method API is the abstraction boundary for the code in the method's body.
We can make the same argument for a default
method. The method body may do things that are common to the implementation of all instances of all descendents of the interface, but the details are still hidden from the caller. That is the abstraction boundary.
What default
and static
methods are doing is to allow the abstraction boundary to be implemented further up the inheritance graph. If you are using them correctly, this is a good thing because it is removing redundant or duplicative code.
1 - It is up to the programmer to design and implement an API to not be a leaky abstraction. Simply using interfaces doesn't address this.

- 698,415
- 94
- 811
- 1,216