给出程序的运行结果 class Person
举一反三
- 给出程序的运行结果()class Person {String name;...;person.tell();}}
- 阅读下列的程序 class Person{ static{ System.out.println("static") } Person(){ System.out.println("构造") } } class Demo{ public static void main(String[] args){ Person p = new Person(); } } 下列选项中,程序的运行结果是()
- 请阅读下面的程序代码,选择正确的运行结果 Class Person{ void say(){ System.out.println(“hello”); } } class Example{ public static void main(String[] args){ Person p2 = new Person(); Person p1 = new Person(); p1.say(); p2.say();} }
- 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
- 给出程序的运行结果() 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(); } }