5th Time Java Job +lsyang

Source: Internet
Author: User

"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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.