What is Abstract Class in Java?

Java abstract class is a class that can not be initiated by itself, it needs to be subclassed by another class to use its properties. An abstract class is declared using the “abstract” keyword in its class definition.

Illustration of Abstract class

abstract class Shape 
{
int color;
// An abstract function
abstract void draw();
}

In Java, the following some important observations about abstract classes are as follows:

  1. An instance of an abstract class can not be created.
  2. Constructors are allowed.
  3. We can have an abstract class without any abstract method.
  4. There can be a final method in abstract class but any abstract method in class(abstract class) can not be declared as final  or in simpler terms final method can not be abstract itself as it will yield an error: “Illegal combination of modifiers: abstract and final”
  5. We can define static methods in an abstract class
  6. We can use the abstract keyword for declaring top-level classes (Outer class) as well as inner classes as abstract
  7. If a class contains at least one abstract method then compulsory should declare a class as abstract 
  8. If the Child class is unable to provide implementation to all abstract methods of the Parent class then we should declare that Child class as abstract so that the next level Child class should provide implementation to the remaining abstract method

Abstract Class in Java

In Java, abstract class is declared with the abstract keyword. It may have both abstract and non-abstract methods(methods with bodies). An abstract is a Java modifier applicable for classes and methods in Java but not for Variables. In this article, we will learn the use of abstract classes in Java.

Similar Reads

What is Abstract Class in Java?

Java abstract class is a class that can not be initiated by itself, it needs to be subclassed by another class to use its properties. An abstract class is declared using the “abstract” keyword in its class definition....

Examples of Java Abstract Class

1. Example of Abstract Class that has Abstract method...

Properties of Abstract class

...

Conclusion

...

FAQs of Abstract class

Let us elaborate on these observations and do justify them with help of clean java programs as follows....

Also, Read

...