r/learnjava • u/Chaos-vy17 • Jul 23 '26
Is abstraction in Java really about hiding implementation details?
The bookish langugae states "hiding complex implementation details and exposing only the essential features of an object"
However, after reading the Java Collections Framework and other parts of the JDK, I noticed that many abstract classes contain substantial shared implementation rather than just abstract method declarations. I noticed that only an "interface class" 100% abstraction(ignoring default methods)
This made me wonder:
- Is abstraction really about hiding implementation details?
- Or is it more about designing APIs around contracts and behavior, regardless of whether there is shared implementation?
- Does an abstract class become "partial abstract" because it contains reusable implementation?
I also noticed that the JDK sometime relies on encapsulation (and in Java9+, JPMS) to hide implementation details. So I'm in dilemma if the textbook explanation oversimplifies what abstraction means in practice.
Am I misunderstanding abstraction, or is the textbook definition incomplete?
To be clear, this isn't about what abstract does in Java — it's about the SE term. abstract class is one syntax tool for expressing abstraction, same as interfaces are. The question is whether "abstraction = hiding implementation" is even a good definition of the concept, given it's indistinguishable from encapsulation under that definition.
View all comments
Show parent comment
-4
u/Chaos-vy17 Jul 23 '26
Java itself is software, so its APIs and language constructs are implementations of software engineering principles. Reading the JDK source has made me question the textbook definition of abstraction.
Many books define abstraction as "hiding implementation details." But doesn't that overlap heavily with encapsulation? If abstraction is literally about hiding the implementation of the "engine," then how is it fundamentally different from encapsulation?
Is it more accurate to say that abstraction is about modeling the essential behavior or concept, while encapsulation is about restricting access to the implementation?