Definition of Abstraction
Abstraction is the process of hiding the details and exposing only the essential features of a particular concept or object. Computer scientists use abstraction to understand and solve problems and communicate their solutions with the computer in some particular computer language. In this way, we are dealing with ideas rather than worrying about all the particular details. For example, without knowing about all the mechanics about the car, you can drive a car.
Of course, if you are an automotive engineer, then your job is to create the most powerful and high quality vehicle that many people can enjoy driving. You must also know all the details to design software systems, assembly, tooling, evaluate problems, etc. But if you just drive a car, you do not need to know how each component works interactively inside of a car you drive everyday. This concept is about which data or information should be visible and which data or information should be hidden.
Abstraction can be achieved with either abstract classes or interfaces.
Example: Toaster
Here’s an example of abstraction. Suppose you have a typical toaster that pops out toasted bread. How would you describe the functionality of the toaster to a 3 year old? You’d probably tell the child that you put the bread in the slots, push down the toast button, wait for the bread to pop out again, and take out the toasted bread.
This is an abstraction of the toaster. The above description only describes the toaster in terms of what the toaster does (makes bread crispy) and how to use it (put bread in, push the button, get toast out). There is no mention of how the electricity heats up the heat coils or how the toaster knows the toast is done. The implementation details are hidden. They’re irrelevant to the end user!
Example: Email
Email is another good example of how we use abstraction. You interact with your email using the public interface. Your email provider allows you to read, send, search, and organize your email. Even the definition of email is fairly abstract; email is a way to send and receive electronic mail.
The details of how the messages get sent to the correct person, are stored on a server, are encrypted (hopefully),etc are hidden from the user (you!). And once again, the details don’t really matter. All you need to know is what behavior you can expect (read, send, search) and how to interact with your email provider to accomplish those behaviors.
Abstraction refers, in general, to the idea of providing a simplified or higher level interface to a complex system. It is closely related to the idea of a "black box." Abstraction makes it possible to understand or use a system, while ignoring some of the details of what actually goes on in the system. Control abstractions make it possible to implement algorithms on a higher level than machine language. Abstraction is a fundamental concept in computer science.
A class that cannot be used to create objects, and that exists only for the purpose of creating subclasses. Abstract classes in Java are defined using the modifier abstract.
An interface is a class-like structure that only contains method signatures and fields. An interface does not contain an implementation of the methods or any data members.
The methods that can be called by any other class.