How to create an object of an abstract class and interface

前端 未结 12 1242
旧巷少年郎
旧巷少年郎 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条回答
  •  醉酒成梦
    2020-12-09 05:28

    NO, we can't create object out of an interface or Abstract class because

    Main intention of creating an object is to utilize the wrapped methods and data. As interface don't have any concrete implementation hence we cannot.

    For abstract class we may have concrete method or abstract method or both. There is no way for the API developer to restrict the use of the method thats don't have implementation.

    Hope help.

提交回复
热议问题