【简答题】
预测程序运行结果 class Person{ String name; public void setName(String name) { this.name=name;} public String getName() {return name;} } class Student extends Person{ } class Teacher extends Person{ } public class StudentDemo{ public static void main(String []args){ Student s=new Student(); s.setName("Tom"); System.out.println(s.getName()); Teacher t=new Teacher(); t.setName("John"); System.out.println(t.getName()); }}
参考答案:
参考解析:
举一反三