看代码
package com.hiyo.HighClass;
//含有抽象方法的类,就是抽象类
abstract class People {
private String name ;
private int age ;
public People(String name, int age) {
this.setName(name);
this.setAge(age);
}//抽象类中的构造方法。
public String getName(){
return this.name;
}
public int getAge(){
return this.age ;
}
public void setAge(int age) {
this.age = age ;
}
public void setName(String name) {
this.name = name ;
}
public abstract String getInfo() ;
//抽象方法,抽象类中的抽象方法。
}
class Boy extends People {
private String school ;
public Boy(String name, int age, String school) {
super(name, age) ;
//子类中调用父类的构造方法
this.setSchool(school) ;
}
public String getSchool() {
return this.school ;
}
public void setSchool(String school) {
this.school = school ;
}
public String getInfo(){
return super.getName() + " " +
super.getAge() + " " +
this.getSchool() ;
}
}
public class AbstractDemo01 {
public static void main(String[] args) {
Boy boy = new Boy("DYJ",30, "NIT");
System.out.println(boy.getInfo());
}
}



