How to create an object of an abstract class and interface

前端 未结 12 1243
旧巷少年郎
旧巷少年郎 2020-12-09 04:36

How do I create an object of an abstract class and interface? I know we can\'t instantiate an object of an abstract class directly.

12条回答
  •  旧时难觅i
    2020-12-09 05:18

    No, you are not creating the instance of your abstract class here. Rather you are creating an instance of an anonymous subclass of your abstract class. And then you are invoking the method on your abstract class reference pointing to subclass object.

提交回复
热议问题