Since we can't instantiate an abstract class, then what is the necessity of having constructors in abstract class?
Abstract classes are designed to be extended, each constructor from the child must perform a call to a constructor from the base class, thus you need constructors in your abstract class.
The abstract class is a skeleton and thus makes no sense to instantiate it directly since it is still incomplete (children will provide the rest).
We can use a abstract class constructor to execute code that is relevant for every subclass. This way preventing duplicate code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With