I have searched about this topic everywhere that what's the difference between abstraction and encapsulation
, even one of the most voted stack overflow question , but at the end it seems confusing for ex - this was an example i found from the internet Real-World Example
1-->In a car, the abstraction is the steering wheel and pedals; you don’t need to know how the engine works.
2-->car’s engine encapsulates its internal workings; you interact with it through the car’s controls without accessing the engine directly.
the first one is the example of the abstract class and the second one is of encapsulation , i didnot get what's the difference between , both are looking the same
i do not want the bookish definition , i am really confused with it , what's the core difference between two , what points i can think so that both will appear distinct to me
Example of abstraction: an
interface Storagewith a methodsave. In fact, we are thinking here about something common between all possible implementations - the interface.Example of encapsulation:
class JdbcStoragewith constructorJdbcStorage(Connection connection). In fact, we are put into “capsule” connection (hiding connection inside an object of the JdbcStorage class).