Package Com.ctgu.java;public class Mankind {private int sex;private int salary;public int getsex () {return sex;} public void setsex (int sex) {this.sex = sex;} public int getsalary () {return salary;} public void setsalary (int salary) {this.salary = salary;} public void Manorwomen () {if (sex = = 1) System.out.println ("man"), else if (sex = = 0) System.out.println ("women"); else SYSTEM.OUT.PRINTLN ("You entered the wrong");} public void Employees () {if (salary = = 0) System.out.println ("No Job"), else if (Salary > 0) System.out.println ("Job");}}
Package Com.ctgu.java;public Class Kids extends Mankind {private int yearsold;public int getyearsold () {return yearsold;} public void Setyearsold (int yearsold) {this.yearsold = Yearsold;} public void Printage () {System.out.println (This.yearsold + "Years");}}
Package Com.ctgu.java;public class Testkids {public static void main (string[] args) {Kids somekids = new Kids (); SOMEKIDS.S Etsalary (Somekids.setsex); Somekids.setyearsold (1); Somekids.employees (); Somekids.manorwomen (); Somekids.printage ();}}
Practice learning notes for inheriting classes