多选题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 the elements within that set.CThe hashCode method for a given class can be used to test for object inequality, but NOT objecte quality, 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.

多选题
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 the elements within that set.

C

The hashCode method for a given class can be used to test for object inequality, but NOT objecte quality, 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.


参考解析

解析: 暂无解析

相关考题:

Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo()method, which two statements are true?() A.The class implements java.lang.Comparable.B.The class implements java.util.Comparator.C.The interface used to implement sorting allows this class to define only one sort sequence.D.The interface used to implement sorting allows this class to define many different sort sequences.

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.

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.

Which statements concerning the methods notify() and notifyAll() are true?  A、Instances of class Thread have a method called notify().B、A call to the method notify() will wake the thread that currently owns the monitor of the object.C、The method notify() is synchronized.D、The method notifyAll() is defined in class Thread.E、When there is more than one thread waiting to obtain the monitor of an object, there is no way to be  sure which thread will be notified by the notify() method.

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.

Which of the following statements are true?() A、 The equals() method determines if reference values refer to the same object.B、 The == operator determines if the contents and type of two separate objects match.C、 The equals() method returns true only when the contents of two objects match.D、 The class File overrides equals() to return true if the contents and type of two separate objects match.

Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()A、The class implements java.lang.Comparable.B、The class implements java.util.Comparator.C、The interface used to implement sorting allows this class to define only one sort sequence.D、The interface used to implement sorting allows this class to define many different sort sequences.

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 statements are true about using the isUserInRole method to implement security in a Java EEapplication?()A、It can be invoked only from the doGet or doPost methods.B、It can be used independently of the getRemoteUser method.C、Can return "true" even when its argument is NOT defined as a valid role name in the deployment descriptor.D、Using the isUserInRole method overrides any declarative authentication related to the method in which it is invoked.

Which statement is true?()A、A class’s finalize() method CANNOT be invoked explicitly.B、super.finalize() is called implicitly by any overriding finalize() method.C、The finalize() method for a given object is called no more than once by the garbage collector.D、The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.

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 the elements within that set.C、The hashCode method for a given class can be used to test for object inequality, but NOT objecte quality, 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.

多选题Which of the following statements are true?()AThe equals() method determines if reference values refer to the same object.BThe == operator determines if the contents and type of two separate objects match.CThe equals() method returns true only when the contents of two objects match.DThe class File overrides equals() to return true if the contents and type of two separate objects match.

单选题Under which circumstances will a thread stop?()AThe method waitforId() in class MediaTracker is called.BThe run() method that the thread is executing ends.CThe call to the start() method of the Thread object returns.DThe suspend() method is called on the Thread object.EThe wait() method is called on the Thread object.

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

多选题You want to create a filter for your web application and your filter will implement javax.servlet.Filter. Which two statements are true?()AYour filter class must implement an init method and a destroy method.BYour filter class must also implement javax.servlet.FilterChain.CWhen your filter chains to the next filter, it should pass the same arguments it received in its doFiltermethod.DThe method that your filter invokes on the object it received that implements javax.servlet.FilterChaincan invoke either another filter or a servlet.EYour filter class must implement a doFilter method that takes, among other things, anHTTPServletRequest object and an HTTPServletResponse object.

多选题Which two are true?()AA finalizer may NOT be invoked explicitly.BThe finalize method declared in class Object takes no action.Csuper.finalize()is called implicitly by any over riding finalize method.DThe finalize method for a given objec twill be called no more than once by the garbage collector.EThe order in which finalize will be called on two objects is based on the order in which the two objects became finalizable.

多选题Which statements concerning the methods notify() and notifyAll() are true?AInstances of class Thread have a method called notify().BA call to the method notify() will wake the thread that currently owns the monitor of the object.CThe method notify() is synchronized.DThe method notifyAll() is defined in class Thread.EWhen there is more than one thread waiting to obtain the monitor of an object, there is no way to be  sure which thread will be notified by the notify() method.

单选题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 statement is true?()AA class’s finalize() method CANNOT be invoked explicitly.Bsuper.finalize() is called implicitly by any overriding finalize() method.CThe finalize() method for a given object is called no more than once by the garbage collector.DThe order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.

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

多选题Given a class whose instances, when found in a collection of objects, are sorted by using the compare To method, which two statements are true?()AThe class implements java.lang.Comparable.BThe class implements java.util.Comparator.CThe interface used to implement sorting allows this class to define only one sort sequence.DThe interface used to implement sorting allows this class to define many different sort sequences.

单选题Given: Which statement 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 methods from the String and StringBuffer classes modify the object on which they are called?()AThe charAt() method of the String class.BThe toUpperCase() method of the String class.CThe replace() method of the String class.DThe reverse() method of the StringBuffer class.EThe length() method of the StringBuffer class.

单选题Which statement 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 statements are true about using the isUserInRole method to implement security in a Java EEapplication?()AIt can be invoked only from the doGet or doPost methods.BIt can be used independently of the getRemoteUser method.CCan return true even when its argument is NOT defined as a valid role name in the deployment descriptor.DUsing the isUserInRole method overrides any declarative authentication related to the method in which it is invoked.

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