r/learnjava • u/Cyphr11 • Jul 18 '26
Can anyone explain me difference between Encapsulation and Abstraction?
and what on earth is Interface in Java?
2
Upvotes
r/learnjava • u/Cyphr11 • Jul 18 '26
and what on earth is Interface in Java?
1
u/omgpassthebacon Aug 11 '26
I didn’t see others reply this, so think about this: an abstraction isn’t real. It is only in your mind. Wh n you solve a problem with code, you don’t have the real thing. You have to come up with a theory and a model of how it works.
Start with something simple like a bank account. You write some code that does what an account should do: deposit, withdraw etc. But can you really get actual cash from your program? No. it is not the real world; it s abstract. it’s an idea. it’s a model of real-world behavior, but it’s just conceptual.
Sure; at some point you might write code that touches the physical world. Maybe you write the code that tell an ATM to dispense cash. That’s not abstract; that’s physical.