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

    内容

    • 0

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

    • 1

      下面哪个程序变量age的定义是正确的() A: public class Employee{ public void show(){ System.out.println(age); } public int age; } B: public class Employee{ public void show(){ System.out.println(age); int age = 20; } } C: public class Employee{ public void show(){ System.out.println(age); } }

    • 2

      下列对结构体类型变量定义不正确的是( ) A: struct teacher { int num; int age; }teach1; B: struct { int num; int age; }teach1,teach2; C: struct { int num; int age; }teacher; struct teacher teach1; D: struct teacher { int num; int age; }; struct teacher teach1;

    • 3

      已知:创建了一个Scanner类型的对象sc,下列语句正确的是() A: int age = sc.next(); B: int age = sc.nextShort(); C: int age = sc.nextByte(); D: double age = sc.nextDouble();

    • 4

      下列( )方法定义和调用的代码是正确的。 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);