Computer Science, asked by CHAKRIKADARI6883, 1 year ago

how abstraction and encapsulation are interrelated and implemented

Answers

Answered by amanpeekay0
1

Hey Mate!

Here's the answer!

Abstraction and Encapsulation look similar to each other by its definition. The standard definition of abstraction is showing only necessary features to the user and hide its implementation. On the other hand, Encapsulation is hiding the complexity from the outer world.

To understand Abstraction we will start from the basic meaning of Abstraction. Abstract means something, which is in thoughts but not it exists in reality. It is like that we know that what should be done, but we don’t know how it would be done.

Take an example, there is a ‘Shape’ class which contains a method ‘area()’ but we cannot implement area() method here as we do not know what will be the shape(a square, a rectangle, a triangle or any other shape) in future. In that case, we will declare area() in the Shape class and will implement the same method in our subclasses as per the requirement.

Similar questions