• 2022-06-01 问题

    关于Employee类的对象说法错误的是() public class Employee{ private int age; private String name; public Employee(){ } public Employee(int age,String name){ this.age = age; this.name = name; } } public class TestEmployee{ public static void main(String[] args){ Employee e1 = new Employee(); Employee e2 = new Employee(10,"tom"); Employee e3 = e2; Employee e4 = new Employee(10,"tom"); } } A: e1对象的name和age属性的值是默认值null和0 B: e2和e3指向相同的内存空间,即指向同一个对象 C: e3和e4对象的age属性值都是10,name属性值都是"tom",所以是同一个对象 D: 表达式e2==e3的值为true,e3==e4的值为false

    关于Employee类的对象说法错误的是() public class Employee{ private int age; private String name; public Employee(){ } public Employee(int age,String name){ this.age = age; this.name = name; } } public class TestEmployee{ public static void main(String[] args){ Employee e1 = new Employee(); Employee e2 = new Employee(10,"tom"); Employee e3 = e2; Employee e4 = new Employee(10,"tom"); } } A: e1对象的name和age属性的值是默认值null和0 B: e2和e3指向相同的内存空间,即指向同一个对象 C: e3和e4对象的age属性值都是10,name属性值都是"tom",所以是同一个对象 D: 表达式e2==e3的值为true,e3==e4的值为false

  • 1