Does invoking a constructor mean creating object?

前端 未结 8 1516
情书的邮戳
情书的邮戳 2020-12-06 05:26

When we create a Subclass object which extends an abstract class, the abstract class constructor also runs . But we know we cannot create objects of an abstract class. Hence

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 05:51

    Subclass == BaseClass + Extras you add in sub class

    Thus when you create a subclass by calling its constructor, there is a call to base class constructor as well to make sure that all attributes (of the base class) are also properly initialized.

提交回复
热议问题