Abstraction in OOPS
There are lots of examples of abstraction in the real world. When it comes to abstraction, it means to hide. Applying an object by knowing only its external properties without looking at its internal details. To give real-world examples, we can count: Car, Washing Machine, Airplane. It is done by simply turning the ignition in the car while a person is driving the car or plane. There is no need to know all the features of the car. Already the buried side of the car is hidden from everyone. The functions of the aircraft are the same. The pilot controls the plane at the front, but is not interested in the hidden buried side of the plane. People who use the washing machine only control the washing machine with their buttons. The software and hardware side of the washing machine is hidden from people. Abstraction means hiding a job or situation from the real world.
On the software side, abstraction is called abstraction when the properties or behaviors of a class are hidden from other classes. These properties and behaviors are exported with the help of certain methods. This hiding event is determined by access specifiers. Only the parts that are important in the project are taken.
Access Specifiers: Public, private, protected, default.
Types of Abstraction
Data Abstraction
Process Abstraction
1.Data Abstraction
Data abstraction happens when an object is hidden from the outside world. This abstraction is provided by private. If it will be used by another program, it is exported with getter/setter methods.
The figure above contains both abstraction and encapsulation. Encapsulation will be explained in the next article :).
2. Process Abstraction
Some properties of objects are hidden from the real world. Others are available in the real world.
Let’s do a basic example of abstraction.
The animal object is created as an interface. Animals will be able to get the necessary information from this animal interface according to their behavior and characteristics.
The lion class got its other two behaviors from the animal interface, except for its own behavior.
We ran the program.
Thank you so much for reading. :))