java学习46天2020/8/20
public class student1 { protected String name; protected int classid; protected int id; public student1(String str,int n,int m) { name=str;classid=n;id=m; } public void move() { System.out.println("上课,学习"); } public void display() { System.out.println("姓名"+name+" "+"班级"+classid+" "+"学号"+id); } }
public class teacher extends student1{ protected int tid; protected int salary; public teacher(String str,int k,int s,int n,int m) { super(str,k,s); tid=n;salary=m; } public void tmove() { System.out.println("批改作业,备课,上课"); } void tdisplay() { System.out.println("工号"+tid+" "+"工资"+salary); } public static void main(String [] args) { teacher m=new teacher("asd",5,001,0065,8000); m.move(); m.tmove(); m.display(); m.tdisplay(); } }
二.使用super来引用父类构造函数
三,例题