在下面的Java代码中,哪一行代码是错误的(): public class...
发布于 2022-03-03 17:35:35
在下面的Java代码中,哪一行代码是错误的():
public class Test{
public static void main(String[] args) {
Parent b1 = new Child()
Child b2 = new Child()
b1.m1() //1
b1.m3() //2
b2.m1() //3
b2.m2() //4
}
}
class Parent{
public void m1(){}
public void m2(){}
}
class Child extends Parent{
public void m1(){}
public void m3(){}
}
public class Test{
public static void main(String[] args) {
Parent b1 = new Child()
Child b2 = new Child()
b1.m1() //1
b1.m3() //2
b2.m1() //3
b2.m2() //4
}
}
class Parent{
public void m1(){}
public void m2(){}
}
class Child extends Parent{
public void m1(){}
public void m3(){}
}
登录后免费查看答案
关注者
0
被浏览
65