java这道题怎么做,求大神帮忙看看
2个回答
展开全部
CollegeStu类:
package answer08;
import answer07.Student;
public class CollegeStu extends Student{
private String unit;
public CollegeStu(String name,int age,String unit){
this.unit=unit;
new Student(name,age);
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public void showInfo(){
System.out.println("姓名:"+super.getName()+" 年龄:"+super.getAge()+" 专业:"+unit);
}
}
CollegeStuTest类:
package answer08;
import answer07.Student;
public class CollegeStuTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s=new CollegeStu("李四",21,"计算机");
s.showInfo();
}
}
追问
十分感谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询