下列针对int类型的私有属性age的访问器方法格式正确的是?
A: int getAge(int age)
B: int setAge()
C: void getAge(int age)
D: void setAge(int age)
A: int getAge(int age)
B: int setAge()
C: void getAge(int age)
D: void setAge(int age)
举一反三
- 下列针对int类型的私有属性age的访问器方法格式正确的是
- 分析下面的程序,输出的结果是? public class Test { public static void main(String[] args) { final Person p = new Person("张三", 23); p.setName("李四"); p.setAge(24); System.out.println(p); } } class Person { private String name; private int age; public Person() { super(); } public Person(String name, int age) { super(); this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "我的姓名是:" + name + ",我的年龄是:" + age ; } }
- class Person { int age; public Person(int age) { ______________//让局部变量的age给成员变量的age赋值 } public int getAge() { return this.age; } } 在横线处填入正确的代码,可以让局部变量的age给成员变量的age赋值
- 下列对结构类型变量不正确的定义是 A: struct teacher{ int num; int age; }teacher1; B: struct{ int num; int age; }teacher1,teacher2; C: struct{ int num; int age; }teacher D: struct teacher{ int num,age; }a;
- 下列描述中,()不是方法重载。 A: void Show(){}和void Show(string name){} B: string Show(string name){}和void Show(string name){} C: string Show(int age){}和void Show(string name){} D: void Show(int age){}和void Show(int age,string name){}