接口和抽象类广告方法覆盖
问题描述:
代码如下:
interface hi
{
public void meth1();
}
abstract class Hullo
{
public abstract void meth1();
}
public class Hello extends Hullo implements hi
{
public void meth1(){}
}
问题:代码编译和一切.我想知道 Hello 类中的 meth1() 覆盖了哪个 meth1()?接口中的ont还是抽象类中的ont,为什么?
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.