【简答题】
预测程序运行结果 class Person { int num1=0; public void show() { System.out.println("num1:"+num1);}} class Student extends Person{ int num2=10; public void show(){ System.out.println("num2:"+num2);}} class Teacher extends Person{ int num2=20; public void show(){ System.out.println("num2:"+num2);}} public class StudentDemo{ public static void main(String []args){ Person p=new Person(); p.show(); p=new Student(); p.show(); p=new Teachr(); p.show(); }}
参考答案:
参考解析:
举一反三