Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 7

Abstraction

by: Kenneth Lazam Boni


Abstraction is the act of representing essential
features without including the background
details. Data abstraction involves giving the
outside environment only the key facts about the
data while hiding the background specifics or
explanations. Technically abstract means
something incomplete or to be completed later.

Abstraction
Function of Abstraction is the concept of object-
oriented programming that “shows” only essential
attributes and “hides” unnecessary information. The
main function of abstraction is hiding the unnecessary
details from the users. Abstraction is selecting data from
a larger pool to show only relevant details of the object
to the user. It helps in reducing programming
complexity and efforts. It is one of the most important
concepts of OOPs.

Abstraction
The keyword abstract can be applied to classes and
methods.

When do we want to mark a class as abstract?


*To force sub classes to implement abstract methods.
*To stop having actual objects of that class.
*To keep having a class reference.
*To retain common class code.

Abstraction
• The main benefit of using an Abstraction in
Programming is that it allows you to group several
related classes as siblings.
• Helps to increase the security of an application or
program as only important details are provided to the
user.
• Avoids code duplication and increases reusability.
• It reduces the complexity of viewing the things.

Benefits of Abstraction
Consider a real life example of a man driving a
car. The man only knows that pressing the
accelerators will increase the speed of car or
applying brakes will stop the car but he does not
know about how on pressing accelerator the speed
is actually increasing, he does not know about the
inner mechanism of the car or the implementation
of accelerator, brakes etc. in the car. This is what
abstraction is.

Example of Abstraction
Output:

Sample Code of Abstraction

You might also like