【多选题】定义了如下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("猪八戒")};
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("猪八戒")};
举一反三
- 下列JavaScript定义对象的语句中,()不正确。 A: var person = {}; B: var person = new Object(); C: person =name; D: function person(name,sex){} var personObj = new person();
- (6-9)定义了如下Person类,下面程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } }
- class Person { String name; int age; [br][/br] public Person(String name, int age) { super(); this.name = name; this.age = age; } @Override public boolean equals(Object obj) { Person person=null; if(obj instanceof Person) person=(Person)obj; if(name.equals(person.name)&&age==person.age) return true; return false; } } class Test{ public static void main(String[] args) { Person person1 = new Person("张三", 12); Person person2 = new Person("张三", 12); System.out.println(person1.equals(person2));//运行结果是? } } 程序运行结果是什么? A: true B: false
- 25.Which of the following is not a good way to welcome a new person? A: a). talk to the new person B: b). give the new person a tour C: c). invite the new person to lunch D: d). ignore the new person's question
- 阅读下面代码: Person 类: public class Person { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } Servlet1: request.getSession().setAttribute("name","zhangsan"); Person p = new Person(); p.setName("lisi"); request.getSession().setAttribute("person",p); Servlet2: String name1 = (String)request.getSession().getAttribute("name"); Person p = (Person)request.getSession().getAttribute("person"); response.getWriter().write(name1); if(p!=null)response.getWriter().write(p.getName()); 浏览器先访问Servlet1,再去访问Servlet2,输出的结果是:()