易搜题 > 资格证大类 > 计算机编程 > 问题详情
问题详情

public class Person {  private name;  public Person(String name) {  this.name = name;  }  public boolean equals(Object o) {  if( !o instanceof Person ) return false;  Person p = (Person) o;  return p.name.equals(this.name);  }  }  Which is true?() 

A、 Compilation fails because the hashCode method is not overridden.

B、 A HashSet could contain multiple Person objects with the same name.

C、 All Person objects will have the same hash code because the hashCode method is not overridden.

D、 If a HashSet contains more than one Person object with name=”Fred”, then removing another person, also with name=”Fred”, will remove them all.

未找到的试题在搜索页框底部可快速提交,在会员中心"提交的题"查看可解决状态。 收藏该题
查看答案

相关问题推荐

  • Which two allow the class Thing to be instantiated using new Thing()?

    A

     public class Thing { }

    B

     public class Thing { public Thing() {} }

    C

     public class Thing { public Thing(void) {} }

    D

     public class Thing { public Thing(String s) {} }

    E

     public class Thing { public void Thing() {} public Thing(String s) {} }

  • 1. class SuperClass {  2. public a geta() {  3. return new a();  4. }  5. }  6. class SubClass extends SuperClass {  7. public b geta() {  8. return new b();  9. }  10. }  Which is true?() 

    A、 Compilation will succeed if a extends b.

    B、 Compilation will succeed if b extends a.

    C、 Compilation will always fail because of an error in line 7.

    D、 Compilation will always fail because of an error in line 8.

  • Which statement is true?()

    A、 Compilation succeeds.

    B、 class A does not compile.

    C、 The method declared on line 9 cannot be modified to throw TestException.

    D、 TestA compiles if line 10 is enclosed in try/catch block that catches TestException.

  • boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()  

    A、 a

    B、 b

    C、 c

    D、 d

    E、 Compilation fails.

  • int index = 1;  int [] foo = new int [3];  int bar = foo [index];  int baz = bar + index;   What is the result?()  

    A、 Baz has the value of 0

    B、 Baz has the value of 1

    C、 Baz has the value of 2

    D、 An exception is thrown.

    E、 The code will not compile.

联系客服 会员中心
TOP