Skip to main content

Abstraction

Abstraction:
Abstraction is a process of hiding the class implementation from its
utilization. The abstraction specified that do not show how object
functionality is implemented but provide an interface to use the
functionality.
To achieved the Abstraction we have to follow the below steps:

  1.  Generalize the behavior of the classes in an interface.
  2. Provide implementation in the class according to the specification
  3. Refer that implementation of the class by using interface reference
    variable
How can we Achieve Abstraction ?
  1.  The abstraction can be achieved either by using abstract class or
    interfaces
  2. If we need pure abstraction then we should use interfaces.
    If we need concrete an abstract method then we should go for abstract
    class
Advantages of abstraction:
  • We can achieved generalization
  • We can hide the implementation
  •  We can achieve loose coupling between the objects.
  •  The abstraction is used to developed API(Application Programming Interface)
  •  The other major advantage of abstraction is any changes in the implementation will have very less impact on the utilization of the class.