继承

package com.jredu.ch06;

public class Engineer {
    String no;
    String name;
    String time;
    
    public void ShowInfo(){
        System.out.println("我的编号:"+no+"我的姓名:"+name+"入职时间:"+time);
    }
    
    public Engineer() {
        super();
    }

    public Engineer(String no, String name, String time) {
        super();
        this.no = no;
        this.name = name;
        this.time = time;
    }
    
}
package com.jredu.ch06;

public class SoftEngineer extends Engineer{
    String type;
    
    public SoftEngineer(String no, String name, String enterTime, String type) {
        super();
        super.no = no;
        super.name = name;
        super.time = enterTime;
        this.type = type;
    }
    @Override
    public void ShowInfo() {
        System.out.println("我的编号:"+no+"我的姓名:"+name+"入职时间:"+time+"种类:"+type);
    }
    public void coding(){
        System.out.println("我不是好人!");
    }
}
package com.jredu.ch06;

public class SoftEngineerTest {

    public static void main(String[] args) {
        SoftEngineer softEngineer = new SoftEngineer("10001", "张三", "2016-08-05", "中文");
        softEngineer.ShowInfo();
        softEngineer.coding();
    }

}

原文地址:https://www.cnblogs.com/xiaolei121/p/5740346.html