Encapsulation hides variables or some implementation that may be changed so often in a class to prevent outsiders access it directly. They must access it via getter and setter methods.

Abstraction is used to hide something too, but in a higher degree (class, interface). Clients who use an abstract class (or interface) do not care about what it was, they just need to know what it can do.

Answer from phnkha on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › difference-between-abstraction-and-encapsulation-in-java-with-examples
Difference between Abstraction and Encapsulation in Java with Examples - GeeksforGeeks
May 4, 2026 - User only calls start() without knowing how it works internally (implementation is hidden). Encapsulation focuses on wrapping data (variables) and methods into a single unit and restricting direct access to the data.
🌐
Unstop
unstop.com › home › blog › 10+ differences between abstraction vs encapsulation in java
10+ Differences Between Abstraction Vs Encapsulation In Java
December 31, 2024 - Similarities Between Java Vs. C++ ... Abstraction hides implementation details and exposes only necessary functionality, focusing on what an object does. Encapsulation bundles data and methods, restricting direct access to protect data integrity.
Discussions

java - Difference between Encapsulation and Abstraction - Stack Overflow
This is a general answer not related to a specific programming language (as was the question). So the answer is: abstraction and encapsulation have nothing in common. But their implementations might relate to each other (say, in Java: Encapsulation - details are hidden in a class, Abstraction ... More on stackoverflow.com
🌐 stackoverflow.com
Difference between abstraction and encapsulation?
I think abstraction is a more generic idea. To abstract is basically to produce a model of something that you want someone to use. For example, a road map is an abstraction for someone that only cares about roads. It doesn't try to capture, say, shops, terrain, how many lanes of traffic there is, etc. Encapsulation is more about hiding implementation details from you and to me, it's a form of abstraction. A real world example might be any electronic device you have, say, a TV remote control. There are buttons to increase the volume, decrease, change channels, etc. Most likely, these just produce infrared signals picked up by your television and the television understands what those signals mean. Maybe a better example is a car with a steering wheel, accelerator, and brakes. This is an abstraction, and the implementation is hidden away in the engine, etc. Indeed, it used to be the case that when you pressed the accelerator, it had a correlation with how much gas was used, but these days, the accelerator is read monitored by a computer, and the computer computes the most efficient way to provide the gas that lets you accelerate, but it can make better adjustments than a direct correlation to the amount of gas used. And, the same abstraction can be used for electric cars that don't use gas at all, yet, you can still have a steering wheel, accelerator, and brakes. More on reddit.com
🌐 r/learnprogramming
8
10
October 23, 2019
ELI5: The difference between Abstraction and Encapsulation in OOPS

Abstraction is basically the idea that the person who is working with a OOP class only needs to know the key information such as the what is the expected data going in and what is the expected results at the end of the call or what is returned.

So I have a function add(num1, num2) that I know it is expecting two numbers and I expect it to add those numbers together and it will return the result. How the adding is done is irrelevant to me (Abstraction). It also means if I decide to change the code on how the adding is done later, as long as the input and result/output remain the same, everything else in the program should work the same without missing a beat.

Encapsulation is basically the idea that the data within an OOP class will remain in that class and should not effect ANY thing else outside of the class. The data is essentially encapsulated. It is important to note that this also means that the functions data is safe from other functions (with exceptions, and depending on language) so you can always rely on the data being the way the class left it.

TL;DR: Abstraction is not caring how a function does, just what it does.

Encapsulation is knowing as long as the function is working properly, the data should be protected.

More on reddit.com
🌐 r/explainlikeimfive
2
1
August 23, 2012
what is encapsulation, inheritance, and polymorphism?
class Foo { public: int length(); private: int begin; int end; }; begin and end are encapsulated. class Bar : public Foo { public: int min(); int max(); }; Bar inherits from Foo. int squareLength(Foo& foo) { int length = foo.length(); return length*length; } Bar bar; int baz = squareLength(bar); bar is passed to squareLength polymorphic. More on reddit.com
🌐 r/cpp_questions
14
2
April 4, 2021
🌐
Board Infinity
boardinfinity.com › blog › abstraction-encapsulation
Abstraction Vs Encapsulation in Java
July 7, 2023 - Encapsulation wraps code and data for unnecessary information, while Abstraction presents only useful data.
🌐
Blogger
javarevisited.blogspot.com › 2017 › 04 › difference-between-abstraction-and-encapsulation-in-java-oop.html
Difference between Abstraction and Encapsulation in Java? OOP Question Answer
4) Abstraction focus on outer lookout ... the vehicle moves. 5) In Java, Abstraction is supported using the interface and abstract class while Encapsulation is supported using access modifiers e.g....
🌐
Great Learning
mygreatlearning.com › blog › it/software development › abstract class and encapsulation in java
Abstract Class and Encapsulation in JAVA
September 3, 2024 - Java: An abstract class is a class that deals with the abstraction of our program and Encapsulation is defined as the wrapping or bundling up of data.
🌐
Baeldung
baeldung.com › home › core concepts › programming › differences between abstraction and encapsulation
Differences Between Abstraction and Encapsulation | Baeldung on Computer Science
March 18, 2024 - So, an interface is like a contract ... implements an interface must implement all its methods. Encapsulation is a mechanism that packs data and methods into a single unit....
Find elsewhere
🌐
Reddit
reddit.com › r/learnprogramming › difference between abstraction and encapsulation?
r/learnprogramming on Reddit: Difference between abstraction and encapsulation?
October 23, 2019 -

They both have extremely similar definitions. I keep getting conflicting information from the internet that varies from "encapsulation is a subset of abstraction" to "encapsulation is a completely different thing than abstraction".

Top answer
1 of 5
9
I think abstraction is a more generic idea. To abstract is basically to produce a model of something that you want someone to use. For example, a road map is an abstraction for someone that only cares about roads. It doesn't try to capture, say, shops, terrain, how many lanes of traffic there is, etc. Encapsulation is more about hiding implementation details from you and to me, it's a form of abstraction. A real world example might be any electronic device you have, say, a TV remote control. There are buttons to increase the volume, decrease, change channels, etc. Most likely, these just produce infrared signals picked up by your television and the television understands what those signals mean. Maybe a better example is a car with a steering wheel, accelerator, and brakes. This is an abstraction, and the implementation is hidden away in the engine, etc. Indeed, it used to be the case that when you pressed the accelerator, it had a correlation with how much gas was used, but these days, the accelerator is read monitored by a computer, and the computer computes the most efficient way to provide the gas that lets you accelerate, but it can make better adjustments than a direct correlation to the amount of gas used. And, the same abstraction can be used for electric cars that don't use gas at all, yet, you can still have a steering wheel, accelerator, and brakes.
2 of 5
3
There are definitely similarities. Encapsulation is essentially saying that we're going to take something and hide it away in a container. Maybe the container provides some way of interacting with the what's in it, but you can't access what's in it directly. This is like private variables with public getters/setters, or APIs in general. Abstraction is saying that we have a specification, and we want to have things that adhere to that specification. It doesn't matter how they're implemented - that's abstracted away. We care about that it behaves the way we want. Thus we can change the implementation without changing the code that uses the abstraction. Now, we see some significant links here. Encapsulation is a way to deal with abstractions - you use the abstraction as an encapsulation of the implementation. You could perhaps contrive of some scenarios where you can have one without the other, but in practice they are inseparable.
🌐
How to do in Java
howtodoinjava.com › home › java object oriented programming › difference between encapsulation and abstraction in java
Difference Between Encapsulation and Abstraction in Java
2 weeks ago - The difference between encapsulation and abstraction in Java is that abstraction decides which operations a type offers to its callers, while encapsulation hides the type’s fields and enforces its rules behind those operations.
🌐
Alma Better
almabetter.com › bytes › articles › difference-between-abstraction-and-encapsulation
Difference Between Abstraction and Encapsulation 2025
March 15, 2025 - Here, the Vehicle class provides abstraction by defining the method start() but not its implementation. Encapsulation in Java is achieved using private fields and public getter and setter methods.
🌐
YouTube
youtube.com › watch
Abstraction and Encapsulation Explained | Core Java Tutorial | Ashok IT - YouTube
🧠 Abstraction vs Encapsulation in Java – Explained Clearly with ExamplesUnderstanding Abstraction and Encapsulation is essential to master Java OOPS concept...
Published: February 13, 2026
🌐
Javatpoint
javatpoint.com › abstraction-vs-encapsulation-in-java
Abstraction vs Encapsulation in Java - Javatpoint
Abstraction vs Encapsulation in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Dinesh on Java
dineshonjava.com › home › difference between abstraction vs encapsulation in java
Difference between Abstraction vs Encapsulation in Java - Dinesh on Java
January 1, 2018 - So in very simple word I am telling you about Abstraction, it is nothing but it is one of the OOP concept which focuses on the process of hiding the unwanted details and exposing only the essential features of a particular object or concept, and Encapsulation is also one of the OOP concepts which also hides data from outside world but there are key differences between them to way of hiding data outside of world.
🌐
NareshIT
nareshit.com › blogs › abstraction-and-encapsulation-in-core-java-explained
Abstraction and Encapsulation in Core Java Explained
Abstraction promotes loose coupling, which means different parts of a system depend less on each other. This improves flexibility and maintainability. Encapsulation means binding data and methods together into a single unit and controlling access ...
🌐
Scribd
scribd.com › document › 888913133 › Abstraction-and-Encapsulation-in-JAVA
Abstraction and Encapsulation in JAVA | PDF
Abstraction involves hiding implementation details through abstract classes and methods, while encapsulation binds data and methods into a single unit for information hiding. It also includes examples of how to implement these concepts using ...
Rating: 5 ​ - ​ 1 votes
🌐
Sarthaks eConnect
sarthaks.com › 3492547 › what-is-the-difference-between-abstraction-and-encapsulation-in-java
What is the difference between abstraction and encapsulation in Java? - Sarthaks eConnect | Largest Online Education Community
In Java, encapsulation is achieved ... In other words, abstraction is about modeling a system at a high level, while encapsulation is about controlling access to the internal details of an object....
🌐
Medium
medium.com › @manishkumar_75473 › mastering-object-oriented-programming-oop-in-java-encapsulation-inheritance-polymorphism-and-12b5c5c4469c
Mastering Object-Oriented Programming (OOP) in Java: Encapsulation, Inheritance, Polymorphism, and Abstraction | by Manish Kumar | Medium
March 12, 2025 - Encapsulation helps in hiding the internal data of an object. Inheritance allows you to reuse code and create a hierarchy. Polymorphism provides flexibility by allowing objects to behave differently.
🌐
Quora
quora.com › What-is-abstraction-and-encapsulation-in-Java
What is abstraction and encapsulation in Java? - Quora
Answer (1 of 4): Abstraction- is basically a process where you show only “relevant” data and “hide” unnecessary details of an object from the user. Its prime aim is to handle complexity by hiding unnecessary details from the user. Assume your mobile phone, you just need to know what ...
🌐
Scribd
scribd.com › doc › 184091755 › DIff-bw-Abstraction-and-Encapsulation-docx
Abstraction vs Encapsulation in Java | PDF | Abstraction (Computer Science) | Object Oriented Programming
The main differences are that abstraction is implemented using interfaces and abstract classes, while encapsulation uses access modifiers like private.
🌐
Hero Vired
herovired.com › learning-hub › blogs › difference-between-abstraction-and-encapsulation
Difference between Abstraction and Encapsulation in Java
June 24, 2024 - Overall, abstraction proves helpful in Java as it allows you to create more manageable and straightforward code, making the process more scalable, readable and maintainable. If you have grown some interest in cloud engineering, the best idea would be to opt for a Cloud engineering course . Encapsulation involves hiding the details of an object’s implementation, limiting access to its internal state.