Why can't we instantiate an interface or an abstract class in java without an anonymous class method?

前端 未结 3 1008
我在风中等你
我在风中等你 2020-12-09 13:00

I know, we can not instantiate either an interface or an abstract class in java except using anonymous class method but what is the reason behind it?

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 13:56

    Here is a basic explanation without deeper concept.

    • Interface has no method implemented, so there is no purpose to instantiate it as 'nothing' will happen when invoke a method
    • Abstract class can have abstract method declaration, which is like a interface method with no implementation.

提交回复
热议问题