给出程序的运行结果()class Person {String name;...;person.tell();}}
举一反三
- 给出程序的运行结果 class Person
- (6-9)定义了如下Person类,下面程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } }
- 给出程序的运行结果() classPerson{ Stringname; intage; Person(){ System.out.println('Person()'); } voidPerson(){ System.out.println('method()'); } publicvoidtell(){ System.out.println('姓名:'+name+',年龄:'+age); } } publicclassClassTest02{ publicstaticvoidmain(String[]args){ Personperson=newPerson(); person.name='张三'; person.age=30; person.tell(); } }
- 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
- 在C#中,下列结构或者类定义正确的是(选一项) A: public struct Person{ string name; int age; public void ShowName(){ Console.WriteLine(name); }} B: public struct Person{ string name; int age; public Person(){ Conssole.WriteLine(name); }} C: public class Person{ string name; int age; public Person(){ Conssole.WriteLine(name); }} D: public class Person{ string name; int age; public Person(string name){ Conssole.WriteLine(name); }}