搜题
问题   更新时间2023/4/3 12:59:00

下面程序是否有错?如果有错试标出错误位置并指出是何种错误。
interface MyInterface
{
void method1();
}
abstract class Parent implements MyInterface
{
}
class Child extends Parent
{
void method1()
{
System.out.println(“I am implemented now!”);
}
}

您的答案: 程序有错,接口MyInterface中的方法method1()缺省是public的, 题中Child类在实现接口时缩小了范围。 改正如下: interface MyInterface { void method1(); } abstract class Parent implements MyInterface { } class Child extends Parent { public void method1() { System.out.println(“I am implemented now!”); } }
王老师:19139051760(拨打)