interface honda {
void meth();
protected void meth2();
}
class crv : honda {
void honda.meth() { } //public not allowed
void honda.meth2() { } //protected not allowed
}
我给出了接口honda
,它有两个抽象方法:
Meth();即public
方法2();即protected
当我在实现类crv
中指定public void honda.meth(){}
或protected honda.meth2() { }
时,会出现什么错误?
我的意思是我有一个假设:这是因为这样做,我们为方法提供默认实现,所以它类似于接口中,但它不是.当我说public void honda.meth(){}
时,这一假设将证明错误是正确的,但当我try 说protected honda.meth2() { }
时,这并不能证明错误是正确的,因为接口中的meth2()
是protected.
你能帮帮我吗?