运行以下代码时出现错误abstract class A { abstract void callMe(); void callMeToo() { System.out.println("this is concrete method"); }}class B extends A { void callMe() { System.out.println("B's implementation of callme"); }}class AbstractDemo { public static void main(String args[]) { B b = new B(); b.callMe(); b.callMeToo(); }}我收到如下错误消息:运行:线程“main”中的异常 java.lang.RuntimeException:无法编译的源代码 - 错误的树类型:B at abstractdemo.main(abstractdemo.java:28) C:\Users\JARVIS\AppData\Local\NetBeans\Cache\10.0 \executor-snippets\run.xml:111:执行此行时发生以下错误:C:\Users\JARVIS\AppData\Local\NetBeans\Cache\10.0\executor-snippets\run.xml:68:Java 返回: 1 构建失败(总时间:0 秒)
1 回答
千巷猫影
TA贡献1829条经验 获得超7个赞
public class AbstractDemo {
abstract static class A {
public abstract void callMe();
public void callMeToo() { }
}
public static class B extends A {
public void callMe() { }
}
public static void main(String args[]) {
B b = new B();
b.callMe();
b.callMeToo();
}
}
添加回答
举报
0/150
提交
取消