Abstract classes, unlike Interfaces, can be used to suggest the structure of the code that extends it. So suppose I write an abstract class that has one imutable property and I expect all classes that inherit from this to supply this property I could define a constructor that takes this property and define a no-args constructor as private.
Originally posted by debabrata das: why we can have/write constructor of an abstract class, if we can't instantiate. why it is so? It is unnecessary.
It is not unnecessary.
You can regard an abstract class as an incomplete class: some parts of it are implemented, but other parts are left for a concrete subclass to implement. When you create an instance of the subclass, then the constructor of the abstract superclass is also called.
In this example, the constructor of class Animal initializes the field 'name' in the Animal class. So, you see that the constructor is not unnecessary.