Cheat single inheritance in Java?

2019-02-05 01:43发布

I have heard there is a way to cheat single inheritance and implement multiple inheritance in Java. Does anyone know how to implement this(with out using interface)?

Just out of curiosity ;-)

13条回答
趁早两清
2楼-- · 2019-02-05 02:48

Yes you can say that it's a trick and it is very Interesting you cannot inherit multiple classes to a single class but it is possible to implement multiple Interfaces to a class like

public class parents implements first, second{

}

but remember, you have to override methods declared in interfaces.

查看更多
登录 后发表回答