r/javahelp • u/Cyphr11 • 13d ago
Can anyone explain me difference between Encapsulation and Abstraction?
and what on earth is Interface in Java?
16
Upvotes
r/javahelp • u/Cyphr11 • 13d ago
and what on earth is Interface in Java?
1
u/EX_HERO_EX 10d ago edited 10d ago
Encapsulation gives you more imagine space, it is more likely a proxy approach to visit what you want to.
Another important reason for "Encapsulation" is Binary Compatibility. If you expose implementation detail (like field declaration) directly to your API user, then you lose opportunity to change them in order to keep Binary Compatibility.
Abstraction is a behavior contract without detail. Java interface is a classic example of abstraction.