单选题实现equals和hashCode最显而易见的作用是()A比较两个对象标识符的值B比较数据库的两条数据C比较两个组建是否部署在同一个应用服务器上D对象与字段的映射

单选题
实现equals和hashCode最显而易见的作用是()
A

比较两个对象标识符的值

B

比较数据库的两条数据

C

比较两个组建是否部署在同一个应用服务器上

D

对象与字段的映射


参考解析

解析: 暂无解析

相关考题:

WhatistheappropriatedefinitionofthehashCodemethodinclassPerson?() A.returnsuper.hashCode();B.returnname.hashCode()+age*7;C.returnname.hashCode()+comment.hashCode()/2;D.returnname.hashCode()+comment.hashCode()/2-age*3;

classSock{Stringsize;Stringcolor;publicbooleanequals(Objecto){Socks=(Sock)o;returncolor.equals(s.color);}//insertcodehere}哪两个满足hashCode的约定?() A.publicinthashCode(){return343;}B.publicinthashCode(){returnsize.hashCode();}C.publicinthashCode(){returncolor.hashCode();}D.publicinthashCode(){return(int)(Math.random()*1000);

程序员正在进行一个项目,必须实现equals方法与所给的hashCode方法协调运行:()publicinthashCode(){return(size.hashCode()+color.hashCode())*17;}哪一个equals方法支持此目标?() A.无法确定B.publicbooleanequals(Objecto){Socks=(Sock)o;returnsize.equals(s.size);}C.publicbooleanequals(Objecto){Socks=(Sock)o;returncolor.equals(s.color);}D.publicbooleanequals(Objecto){Socks=(Sock)o;returnsize.equals(s.size)color.equals(s.color);}

publicclassPerson{privateStringname,comment;privateintage;publicPerson(Stringn,inta,Stringc){name=n;age=a;comment=c;}publicbooleanequals(Objecto){if(!(oinstanceofPerson))returnfalse;Personp=(Person)o;returnage==p.agename.equals(p.name);}}WhatistheappropriatedefinitionofthehashCodemethodinclassPerson?()A.returnsuper.hashCode();B.returnname.hashCode()+age*7;C.returnname.hashCode()+comment.hashCode()/2;D.returnname.hashCode()+comment.hashCode()/2-age*3;

Given:WhatistheappropriatedefinitionofthehashCodemethodinclassPerson?() A.returnsuper.hashCode();B.returnname.hashCode()+age*7;C.returnname.hashCode()+comment.hashCode()/2;D.returnname.hashCode()+comment.hashCode()/2-age*3;

YouwanttouseteCoherenceJavaAPIstodirectlycachedPOJOs.Considerthissnippetofcode:NamedCachecache-CacheFactory.getCache(mycache);cache.put(newInteger(I)fhello);cache.put(T,hi);cache.put(newLong(II),hey);Thiscodeinsertsthreeobjectsintothecache.Why?()A.hashCode()andequals()methodforeachobjecttypeisdifferentsoadifferentkeyisusedB.eachobjectvaluestringisdifferentsoadifferentvalueisinsertedoneachputC.equals()andcompare()methodisdifferentforeachputD.POFneedtobeimplementedforthistoworkproperly

下列有关HashSet集合的描述中,错误的是() A.HashSet是Set接口的一个实现类B.向HashSet存入对象时,对象一般会重写hashCode ()和equals ()方法C.向HashSet存入对象时,对象的equals ()方法一定会被执行D.HashSet存储的元素是不可重复的

public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age  name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?() A、 return super.hashCode();B、 return name.hashCode() + age * 7;C、 return name.hashCode() + comment.hashCode() /2;D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;

Which two statements are true about the hashCode method?()A、 The hashCode method for a given class can be used to test for object equality and object inequality for that class.B、 The hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.C、 The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.D、 The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.E、 The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

程序员正在进行一个项目,必须实现equals方法与所给的hashCode方法协调运行:()  public int hashCode() {   return (size.hashCode() + color.hashCode()) * 17;   }   哪一个equals方法支持此目标?()  A、 无法确定B、 public boolean equals(Object o) {  Sock s = (Sock) o;return size.equals(s.size);  } C、 public boolean equals(Object o) {  Sock s = (Sock) o;return color.equals(s.color); }D、 public boolean equals(Object o) {  Sock s = (Sock) o;return size.equals(s.size) color.equals(s.color); }

如果你设计了一个类,并且覆盖了equals( )方法,哪些方法你还会考虑覆盖()A、clone()B、toString()C、wait()D、finalize()E、hashCode()

两个对像值相同(x.equals(y)==true),但却可有不同的hashcode,这句话对不对?

HashSet子类依靠()方法区分重复元素。A、toString()、equals()B、clone()、equals()C、hashCode()、equals()D、getClass()、clone()

实现equals和hashCode最显而易见的作用是()A、比较两个对象标识符的值B、比较数据库的两条数据C、比较两个组建是否部署在同一个应用服务器上D、对象与字段的映射

Which two statements are true regarding the return values of property written hashCode and equals methods from two instances of the same class?()A、 If the hashCode values are different, the objects might be equal.B、 If the hashCode values are the same, the object must be equal.C、 If the hashCode values are the same, the objects might be equal.D、 If the hashCode values are different, the objects must be unequal.

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.

public class Key {  private long id1;  private long 1d2;  // class Key methods  }  A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()A、 public int hashCode()B、 public boolean equals(Key k)C、 public int compareTo(Object o)D、 public boolean equals(Object o)E、 public boolean compareTo(Key k)

单选题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.

单选题1. public class Person {  2. private String name;  3. public Person(String name) { this.name = name; }  4. public boolean equals(Person p) {  5. return p.name.equals(this.name);  6. }  7. }  Which is true?()A The equals method does NOT properly override the Object.equals method.B Compilation fails because the private attribute p.name cannot be accessed in line 5.C To work correctly with hash-based data structures, this class must also implement the hashCode method.D When adding Person objects to a java.util.Set collection, the equals method in line 4 will prevent duplicates.

单选题public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age  name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?()A return super.hashCode();B return name.hashCode() + age * 7;C return name.hashCode() + comment.hashCode() /2;D return name.hashCode() + comment.hashCode() / 2 - age * 3;

多选题class Sock {  String size;  String color;  public boolean equals(Object o) {  Sock s = (Sock) o;  return color.equals(s.color);   }  // insert code here  }  哪两个满足 hashCode 的约定?()Apublic int hashCode() { return 343; }Bpublic int hashCode() { return size.hashCode (); }Cpublic int hashCode() { return color.hashCode (); }Dpublic int hashCode() { return (int) (Math.random() * 1000);

单选题实现equals和hashCode最显而易见的作用是()A比较两个对象标识符的值B比较数据库的两条数据C比较两个组建是否部署在同一个应用服务器上D对象与字段的映射

多选题Which two statements are true regarding the return values of property written hashCode and equals methods from two instances of the same class?()AIf the hashCode values are different, the objects might be equal.BIf the hashCode values are the same, the object must be equal.CIf the hashCode values are the same, the objects might be equal.DIf the hashCode values are different, the objects must be unequal.

单选题如下关于Java编码描述不正确的是()A除了构建器外,不要使用和类名相同的方法名B使用equals()比较两个类的值是否相同C不要使用嵌套赋值,即在一个表达式中使用多个=D重载equals()方法时,不必要重载hashCode()方法

单选题You want to use te Coherence Java APIs to directly cached POJOs. Consider this snippet of code: NamedCache cache - CacheFactory.getCache("mycache");  cache.put(new Integer(I)f "hello"); cache.put(T,"hi");  cache.put(new Long(II),"hey");  This code inserts three objects into the cache.  Why ?()A hashCode() and equals() method for each object type is different so a different key is usedB each object value string is different so a different value is inserted on each putC equals() and compare() method is different for each putD POF need to be implemented for this to work properly

问答题两个对像值相同(x.equals(y)==true),但却可有不同的hashcode,这句话对不对?

多选题Which two statements are true about the hashCode method?()AThe hashCode method for a given class can be used to test for object equality and object inequality for that class.BThe hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.CThe hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.DThe only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.EThe hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

单选题程序员正在进行一个项目,必须实现equals方法与所给的hashCode方法协调运行:  public int hashCode() {    return (size.hashCode() + color.hashCode()) * 17;    }    哪一个equals方法支持此目标?()A 无法确定B public boolean equals(Object o) {  Sock s = (Sock) o; return size.equals(s.size);}C public boolean equals(Object o) {  Sock s = (Sock) o; return color.equals(s.color);}D public boolean equals(Object o) {  Sock s = (Sock) o; return size.equals(s.size) color.equals(s.color);  }