Does invoking a constructor mean creating object?

前端 未结 8 1523
情书的邮戳
情书的邮戳 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:53

    This is how the flow works when you invoke the constructor of your subclass:

    1. Constructor of Abstract class runs --> the object is half initialized here.
    2. Constructor of subclass finishes execution --> The object is fully initialized and hence completely created here.

提交回复
热议问题