Search This Blog

Tuesday, November 13, 2018

Constructorof abstract class in Java

Abstract class can have constructor in Java. You can either explicitly provide constructor to abstract class or if you don't, compiler will add default constructor of no argument in abstract class. This is true for all classes and its also applies on abstract class.

When any class extend abstract class, constructor of sub class will invoke constructor of super class either implicitly or explicitly. This chaining of constructors is one of the reason abstract class can have constructors in Java.