62,623
社区成员
发帖
与我相关
我的任务
分享
class Person {
String name;
int age;
public void getInfo() {
System.out.println(name);
System.out.println(age);
}
}
public class Student {
public static void main(String[] args) {
Person p = new Person();
p.name = "person";
p.age = 30;
p.getInfo();
Student1 s = new Student1();
s.name = "student1";
s.age = 13;
s.getInfo("school");
s.Study();
}
}
class Student1 extends Person {
String school = new String();
public void Study() {
System.out.println("Studding");
}
public void getInfo(String school) {
super.getInfo();
System.out.println(school);
}
}