Abstraction - There are times that when you construct a class design applied with inheritance, you don’t want superclasses/supertypes to be instantiated. You only want them to serve as a data type of identifiers for subtyping.
Abstraction can be done if these types are abstract.
Abstraction is an important concept in OOP that allows programmers to focus on the essential details of an object and ignore the rest. This can make it easier to reason about code, simplify code maintenance, and make it easier to develop complex systems.
In OOP, abstraction is achieved through the use of abstract classes and interfaces.
An abstract class is a class that is declared abstract—it may or may not include abstract method/s.
An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon)
All abstract constructs; that includes abstract classes, cannot be instantiated/created. It can only be inherited or used in subtyping.
When an abstract class is inherited into a non-abstract class, the non-abstract class must provide implementation for all the inherited methods that are still abstract. However, if you don’t want it to, then you must declare that class, abstract.
In Java OOP, an interface is a group of related methods with empty bodies. All methods in an interface is, by default, abstract.
An interface can inherit 1 or more existing interfaces. A lass can implement 1 or more interfaces. With the inheritance of the abstract methods from the interfaces, it will still follow the same procedure done on abstract methods inherited from abstract classes.
Abstract constructs, i.e. abstract classes and interfaces, can be used as subtypes to objects instantiated from classes implementing such constructs.