• 2022-06-07
    1、以下变量申明语句,错误的是()。
    A: int age;
    B: final int age = 18;
    C: int age = 18;
    D: int age = 18.5;
  • D

    内容

    • 0

      下列针对int类型的私有属性age的访问器方法格式正确的是? A: int getAge(int age) B: int setAge() C: void getAge(int age) D: void setAge(int age)

    • 1

      下列变量定义形式正确的是? A: int age,year,float, salary; B: int myAge,year;float salary; C: int _age,3year;float my_salary; D: int age;int return;float salary;

    • 2

      下列选项中不能够定义一个结构体类型变量stu的是 。 A: struct student { int num; int age; } stu; B: struct student { int num; int age; }; student stu; C: struct {int num; int age; } stu; D: struct student {int num; int age; }; struct student stu;

    • 3

      下列( )方法定义和调用的代码是正确的。 A: static void Introduce(string gender = "男", string name, int age = 18){} Introduce(name: "alex", age: 20); B: static void Introduce(string name, int age = 18, string gender = "男"){} Introduce(age: 20, name: "alex"); C: static void Introduce(string gender = "男", string name, int ago = 18){} Introduce(age: 20, name: "alex"); D: static void Introduce(string name, int age = 18, string gender = "男"){}Introduce(name: "alex", age: 20);

    • 4

      class Person { int age; public Person(int age) { ______________//让局部变量的age给成员变量的age赋值 } public int getAge() { return this.age; } } 在横线处填入正确的代码,可以让局部变量的age给成员变量的age赋值