知识点:Java 7/10(多选) Given the following...
发布于 2022-03-03 17:30:59
知识点:Java 7/10(多选)
Given the following code fragment, please select the correct descriptions of generated output
public class Parent{
public int m = 0
public void doAction1(){
System.out.println(m)
}
public void doAction2(){
System.out.println(m)
}
}
public class Child extends Parent {
public int m = 1
public void doAction1() {
System.out.println(m)
}
public static void main(String[] args) {
Parent parent = new Child()
parent.doAction1()
parent.doAction2()
System.out.println(parent.m)
Child child = (Child)parent
System.out.println(child.m)
child.doAction1()
}
}
Given the following code fragment, please select the correct descriptions of generated output
public class Parent{
public int m = 0
public void doAction1(){
System.out.println(m)
}
public void doAction2(){
System.out.println(m)
}
}
public class Child extends Parent {
public int m = 1
public void doAction1() {
System.out.println(m)
}
public static void main(String[] args) {
Parent parent = new Child()
parent.doAction1()
parent.doAction2()
System.out.println(parent.m)
Child child = (Child)parent
System.out.println(child.m)
child.doAction1()
}
}
登录后免费查看答案
关注者
0
被浏览
22