写出下面程序的运行结果:[br][/br] private class Person6 { var lastName: String = "zhang" var no: Int = 100 var heiht: Float = 145.4f } fun main(args: Array[String]) { var Person1: Person6 = Person6() Person1.lastName = "wang" println("lastName:${Person1.lastName}") Person1.no = 9 println("no:${Person1.no}") Person1.no = 20 println("no:${Person1.no}") }
举一反三
- 下面代码的输出是什么?() functionPerson(firstName,lastName){ this.firstName=firstName; this.lastName=lastName; } constlydia=newPerson("Lydia","Hallie"); constsarah=Person("Sarah","Smith"); console.log(lydia); console.log(sarah); A: Person{firstName:"Lydia",lastName:"Hallie"}andundefined B: Person{firstName:"Lydia",lastName:"Hallie"}andPerson{firstName:"Sarah",lastName:"Smith"} C: Person{firstName:"Lydia",lastName:"Hallie"}and{} D: Person{firstName:"Lydia",lastName:"Hallie"}andReferenceError
- 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
- 下列JavaScript定义对象的语句中,()不正确。 A: var person = {}; B: var person = new Object(); C: person =name; D: function person(name,sex){} var personObj = new person();
- (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; } }
- var person = {[br][/br] firstName: "Bill", lastName : "Gates", id : 648, fullName : function() { return this.firstName + " " + this.lastName; } }; 请问运行代码console.log(person.fullName())结果为______