class?Person1{
private?String?name?;
private?String?address?;
private?char?sex?;
private?int?age?;
public?Person1()?{
}
public?Person1(String?name,?String?address,?char?sex,?int?age)?{
super();
this.name?=?name;
this.address?=?address;
this.sex?=?sex;
this.age?=?age;
}
public?String?toString()?{
return?"名字:"?+?this.name+?",?地址:"?+?this.address?+?",性別:"?+?this.sex?+?",年齡:"?+?this.age;
}
}
class?Student1?extends?Person1{
private?double?math;
private?double?english;
public?Student1()?{
}
public?Student1(double?math,?double?english)?{
super();
this.math?=math;
this.english?=?english;
}
public?Student1(String?name,?String?address,?char?sex,?int?age,?double?math,?double?english)?{
super(name,?address,?sex,?age);
this.math?=math;
this.english?=?english;
}
public?String?toString()?{
return?super.toString()?+"數(shù)學(xué)成績:"?+?this.math?+",英語成績:"?+?this.english;
}
}
public?class?FouthTest1?{
public?static?void?main(String[]?args)?{
Student1?ss?=?new?Student1("張三"?,?"xian"?,?'男'?,25?,?100.0?,?95.2?);
System.out.println(ss);
Student1?s?=?new?Student1(25.6,93.3);
System.out.println(s);
Student1?sss?=?new?Student1("張三",?"北京",?'男',25);
System.out.println(sss);
}
}
2017-09-22
子類student1的構(gòu)造方法跟父類的構(gòu)造方法參數(shù)不匹配