以下程序片断是否正确? #include "iostream.h" class Person { private: int m_nAge;[br][/br] public:[br][/br] int GetAge();[br][/br] };[br][/br] int Person:: GetAge() { return m_nAge; } void main()[br][/br] { Person person1; person1.m_nAge=10; cout<<person1.GetAge(); }
以下程序片断是否正确? #include "iostream.h" class Person { private: int m_nAge;[br][/br] public:[br][/br] int GetAge();[br][/br] };[br][/br] int Person:: GetAge() { return m_nAge; } void main()[br][/br] { Person person1; person1.m_nAge=10; cout<<person1.GetAge(); }
class Person { int age; public Person(int age) { ______________//让局部变量的age给成员变量的age赋值 } public int getAge() { return this.age; } } 在横线处填入正确的代码,可以让局部变量的age给成员变量的age赋值
class Person { int age; public Person(int age) { ______________//让局部变量的age给成员变量的age赋值 } public int getAge() { return this.age; } } 在横线处填入正确的代码,可以让局部变量的age给成员变量的age赋值
1. The person in dialogue 1 wants to go to the _______________.2. The person in dialogue 2 wants to go to the ______.3. The person in dialogue 3 wants to go to the ______________________.
1. The person in dialogue 1 wants to go to the _______________.2. The person in dialogue 2 wants to go to the ______.3. The person in dialogue 3 wants to go to the ______________________.
1. The person in dialogue 1 wants to go to the _______________.
1. The person in dialogue 1 wants to go to the _______________.
下列针对int类型的私有属性age的访问器方法格式正确的是? A: int getAge(int age) B: int setAge() C: void getAge(int age) D: void setAge(int age)
下列针对int类型的私有属性age的访问器方法格式正确的是? A: int getAge(int age) B: int setAge() C: void getAge(int age) D: void setAge(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 ; } }
分析下面的程序,输出的结果是? 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 ; } }
(6-2)定义如下Person类,(1)处合理的代码是。 class Person { String name, department; int age; public Person(String n) { name = n; } public Person(String n, int a) { name = n; age = a; } public Person(String n, int a, String d) { ① department = d; } }
(6-2)定义如下Person类,(1)处合理的代码是。 class Person { String name, department; int age; public Person(String n) { name = n; } public Person(String n, int a) { name = n; age = a; } public Person(String n, int a, String d) { ① department = d; } }
12. There are _________ (1 word)ages in a person’s existence according to Shakespeare.
12. There are _________ (1 word)ages in a person’s existence according to Shakespeare.
1、With an older person you generally shake hands and smile, of course.
1、With an older person you generally shake hands and smile, of course.
【多选题】定义了如下Person类,下面()程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } } A. Person [ ] list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; B. Person list[ ]=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; C. Person[ ] list={new Person("孙悟空"),new Person("猪八戒")}; D. Person list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")};
【多选题】定义了如下Person类,下面()程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } } A. Person [ ] list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; B. Person list[ ]=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; C. Person[ ] list={new Person("孙悟空"),new Person("猪八戒")}; D. Person list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")};