Abstract class is a special class in Java, it can not be instantiated and that's why can not be used directly. At first concept of abstraction, abstract class and interface all look useless to many developers, because you can not implement any method in interface, you can not create object of abstract class, so why do you need them. Once they face biggest constant of software development, yes that is CHANGE, they understand how abstraction at top level can help in writing flexible software. A key challenge while writing software (Java Programs, C++ programs) is not just to cater today's requirement but also to ensure that nurture requirement can be handled without any architectural or design change in your code. In short, your software must be flexible enough to support future changes. Abstract class and inheritance collectively ensures that most of the code are written using abstract and higher level classes, so that it can leverage
Inheritance and
Polymorphism to support future changes. This is actually one of the most useful design principle, also known as
"Programming for interfaces rather than implementation". Abstract class and abstract method are two ways through which Java assist you on coding at certain level of abstraction. We will look at syntax level details, capability and limitation of abstract class at later half of article, but you must understand
why abstract class is important. More importantly, why you, a Java programmer, must understand motive and use of abstract class. From my years of experience, I can say that making a class at first an
interface or abstract class is a good practice, it will not only help you to test your code quickly by supplying mock objects, but also help you to write code at certain level of abstraction. In this article, we will understand why we need
abstract class and
abstract method and learn how to use them by writing a simple example.