继承

方法的重写 package test1; class ManKind{      intsex;      intsalary;      void manOrWoman()      {          if(sex==0)               System.out.println("man");          else               System.out.println("woman");      }      void employeed()      {          if(sex==0)               System.out.println("no job");          else               System.out.println("job");      } } class Kids extends ManKind{      intyearsOld;      void PrintAge()      {          System.out.println(yearsOld);      } } publicclass Test {      publicstaticvoid main(String[] args) {      Kids A=new Kids();      A.salary=1;      A.sex=1;      A.yearsOld=19;      A.employeed();      A.manOrWoman();      A.PrintAge();      } }

继承继承继承继承

package test1; class ManKind{      intsex;      intsalary;      void manOrWoman()      {          if(sex==0)               System.out.println("man");          else               System.out.println("woman");      }      String employeed()      {          if(sex==0)               return"no job";          else               return"job";        } } class Kids extends ManKind{      intyearsOld;      void PrintAge()      {          System.out.println(yearsOld);      }      String employeed()      {          return"Kids should study and no job";      } } publicclass Test {      publicstaticvoid main(String[] args) {      Kids A=new Kids();      A.salary=1;      A.sex=1;      A.yearsOld=19;      A.employeed();      A.manOrWoman();      A.PrintAge();      System.out.println(A.employeed());      } }

继承继承继承继承

 
上一篇:机器学习--tensorflow报错情况统计


下一篇:Lwip里的tcp的Protocol Control Block