"topic" establishes a human (person) and Student Class (Student) with the following functional requirements:
(1) The person class contains 4 private data members name, addr, sex, age, respectively, string, string, character, and integer, indicating name, address, gender, and ages. A 4-parameter construction method, a two-parameter construction method, a parameterless construction method can be used to instantiate the person, and an output method is used to display 4 properties.
(2) The student class inherits the person class, and adds members math, English, and math. A 6-parameter construction method, a two-parameter construction method, a parameterless construction method, and an overridden output method are used to display 6 properties.
1 classperson{2 PrivateString name;3 PrivateString addr;4 Private Charsex;5 Private intAge ;6 PublicPerson () {7 8 } 9 PublicPerson (String name,string addr,CharSexintAge ) { Ten Super(); One This. name=name; A This. addr=addr; - This. sex=sex; - This. age=Age ; the } - PublicString toString () { - return"Name:" + This. name+ "Address:" + This. Addr + "Gender:" + This. sex+ "Age:" + This. Age; - } + } - classStudentextendsperson{ + Private DoubleMath; A Private Double中文版; at PublicStudent () { - - } - PublicStudent (String name,string addr,CharSexintAgeDoubleMathDouble中文版) { - Super(name,addr,sex,age); - This. math=Math; in This. english=中文版; - } to PublicString toString () { + return Super. toString () + "Math Score:" + This. math+ "English score:" + This. 中文版; - } the } * Public classjava501{ $ Public Static voidMain (string[] args) {Panax NotoginsengStudent stu=NewStudent ("Zhang San", "No. 11th Chaoyang North Road, Chaoyang District, Beijing", ' female ', 20,100,96); - System.out.println (stu); the } +}
Program Run Results
5th Time Java Job +lsyang