How to create an object of an abstract class and interface

前端 未结 12 1241
旧巷少年郎
旧巷少年郎 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:25

    public abstract class AbstractClass { ... }
    
    public interface InterfaceClass { ... }
    
    // This is the concrete class that extends the abstract class above and
    // implements the interface above.  You will have to make sure that you implement
    // any abstract methods from the AbstractClass and implement all method definitions
    // from the InterfaceClass
    public class Foo extends AbstractClass implements InterfaceClass { ... }
    

提交回复
热议问题