抽象类的继承与方法实现

来源:互联网 发布:用eclipse写java程序 编辑:程序博客网 时间:2024/05/01 23:54
public class AbstractTrain extends InformationB{void boss(String str,int age,String str1){this.str=str;this.age=age;this.str1=str1;System.out.println("干部--->姓名: "+this.str+",年龄: "+this.age+",职业: "+this.str1);}void worker(String str,int age,String str1){this.str=str;this.age=age;this.str1=str1;System.out.println("工人--->姓名: "+this.str+",年龄: "+this.age+",职业: "+this.str1);}public static void main(String args[]){AbstractTrain train =new AbstractTrain();train.boss("李乐乐", 20, "干部");train.boss("王小六", 30, "工人");}                           }abstract class InformationA{String str;int age;String str1;abstract void boss(String str,int age,String str1);}abstract class InformationB extends InformationA{abstract void worker(String str,int age,String str1);}

0 0