[Java] 测试定义的类 →→→→→进入此内容的聊天室

来自 , 2019-06-12, 写在 Java, 查看 98 次.
URL http://www.code666.cn/view/c930eecd
  1. class People{
  2.         public String name;
  3.         public String sex;
  4. }
  5.  
  6.  
  7. public class Employee extends People{
  8.     public int age;
  9.     public char grade;
  10.    
  11.     public Employee(){
  12.         this("老王","男",40,'A');
  13.     }
  14.   public Employee(String name,String sex,int age,char grade){
  15.         this.name = name;
  16.         this.sex = sex;
  17.         this.age = age;
  18.         this.grade = grade;
  19.     }
  20.   public String print(){
  21.           return "姓名:" + name + ";\t\t性别:" + sex + ":\t\t年龄:" + age +
  22.                          ":\t\t工资:" + grade ;
  23.   }
  24.          
  25.         public static void main(String[] args) {
  26.                  Employee employee = new Employee();
  27.                  System.out.println(employee.print());
  28.  
  29.         }
  30.  
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  

回复 "测试定义的类"

这儿你可以回复上面这条便签

captcha