Encapsulation Vs Abstraction
Hiding !
Wiki topics:
TLS · Design Tools & Workflow
Encapsulation Vs Abstraction
Hiding !
🔆 Encapsulation is represented by data hiding from direct access, which means information hiding.
It makes variables private and accesses them using public getter and setter methods.
public class Bank {
private double balance = 0;
public double getBalance() {
return balance;
}
public double setBalance() {
this.balance=balance;
}
}
What is happening ?
- The balance variable is private.
- We cannot access them directly.
- This protects data.
🔆 In contrast, Abstraction is used to detail hiding, which means implementation hiding.
Achieved using abstract classes or interfaces.
abstract class Animal {
abstract void sound ();
}
class Dog extends Animal {
void sound () {
System.out.println (“Bark….”);
}
}
class Cat extends Animal {
void sound () {
System.out.println (“Meow….”);
}
}
What is happening ?
- The Animal class hides the implementation of sound().
- We only know that animals make sounds.
- How the dog makes sound is hidden inside the Dog class, and cat makes sound is hidden inside the Cat class.
- This is Implementation Hiding.
Furthermore, Encapsulation focuses on data and methods staying together, but abstraction focuses on the interface, not implementation.

메타데이터
- post_id
- 15da6d1aaa0d
- slug
- encapsulation-vs-abstraction-15da6d1aaa0d
- url
- https://medium.com/@senarathnemalindi/encapsulation-vs-abstraction-15da6d1aaa0d
- canonical_url
- https://medium.com/@senarathnemalindi/encapsulation-vs-abstraction-15da6d1aaa0d
- author_url
- https://medium.com/@senarathnemalindi
- status
- ok
- fetched_at
- 2026-06-09 15:37:30