接口和抽象类广告方法覆盖 [英] Interface and Abstract class ad method overriding
本文介绍了接口和抽象类广告方法覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是代码:
interface hi
pre>
{
public void meth1();
}
抽象类Hullo
{
public abstract void meth1();
}
public class Hello extends Hullo implements hi
{
public void meth1(){}
}
问题:代码编译和一切。我想知道类Hello中的meth1()是覆盖哪个meth1()?
接口中的ont或抽象类中的ont?为什么?解决方案.....
其实,你是重写没有一个,你是实现他们,用一种方法。
Here is the code:
interface hi { public void meth1(); } abstract class Hullo { public abstract void meth1(); } public class Hello extends Hullo implements hi { public void meth1(){} }
Question:The code compiles and everything. I wanted to know the meth1() in class Hello is overriding which meth1()? The ont in the interface or the one in the abstract class and why?
解决方案The answer is short: Both.....
In fact, to be correct: You are overriding none of them, you are implementing them both, with one method.
这篇关于接口和抽象类广告方法覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文