The second process of assessment

Source: Internet
Author: User

The first question.

Student Class-Constructors

Defines a student class for students, containing class member variables: string name, string sex, int age, and all variables must be private.

Program Design idea: According to the topic defines a student's student class, contains the class member variable: string name, string sex, int age, all the variables must be private (private), the construction method student without parameters, Define the construction method with parameters tostring, output name, age, and gender, and create objects in the main function.

Knowledge points used: Defining classes, constructing methods;

Operation Result:

Code Cloud Address: Https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Xuesheng.java

Second question

Define the class, please add the following code to complete the output requirements.

Program Design ideas: Define a fun method with parameters, the return value of the parameter can be used to output a five-digit average.

The knowledge points used: parameter passing value, defining method;

Operation Result:

Code Cloud Address: https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Average.java#

Third question

Horizontal Flat Vertical

Procedural blanks. Refine the code below as required by the topic. Please submit the full code. If the height of a block is larger than the width, we say it is upright, otherwise we say it is flat. Read into the height and width of a block of wood. If it is flat, then output a, otherwise output B.

Program Design ideas: Define class board, define constructors, method overloads with different parameter types, use parameter values to see "A", or "B".

Knowledge points Applied: Method overloads, constructors

Operation Result:

Code Cloud Address: https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Hengpingshuzhi.java#

Question Fourth

Program change the wrong question

Program Design ideas: Define the L class Animal,dog inheritance Animal, because class Animal in the absence of a method to run, the subclass can not inherit the parent class, so you have to add

The knowledge points applied: inheritance and polymorphism.

Operation Result:

Code Cloud Address: Https://gitee.com/changchundehui/16012008/blob/master/16012008/16012008/Chengxugaicuo.java

Learning content Code (line) Blog (word)
Class 30
Constructing methods and objects 50
Method overloading 68
Package 84
Subclasses and inheritance 80
The second process of assessment 100 300

Classroom Practice Code Cloud Address: https://gitee.com/changchundehui/16012008_/tree/master/16012008_

The second process of assessment

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.