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


参考解析

解析: 暂无解析

相关考题:

Click the Exhibit button. Which statement is true about the classes and interfaces in the exhibit?() A.Compilation will succeed for all classes and interfaces.B.Compilation of class C will fail because of an error in line 2.C.Compilation of class C will fail because of an error in line 6.D.Compilation of class AImpl will fail because of an error in line 2

Given:What is the result when method testIfA is invoked?() A.TrueB.Not trueC.An exception is thrown at runtime.D.Compilation fails because of an error at line 12.E.Compilation fails because of an error at line 19.

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;

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 name;  public Person(String name) {  this.name = name;  }  public int hashCode() {  return 420;  }  }  Which is true?() A、 The time to find the value from HashMap with a Person key depends on the size of the map.B、 Deleting a Person key from a HashMap will delete all map entries for all keys of typePerson.C、 Inserting a second Person object into a HashSet will cause the first Person object to beremoved as a duplicate.D、 The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.

11. public static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? () A、 42B、 An exception is thrown at runtime.C、 Compilation fails because of an error on line 12.D、 Compilation fails because of an error on line 16.E、 Compilation fails because of an error on line 17.

Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains: foo frodo Which two are true?()A、The foo initialization parameter CANNOT be set programmatically.B、Compilation fails because getInitParameter returns type Object.C、The foo initialization parameter is NOT a servlet initialization parameter.D、Compilation fails because ServletContext does NOT have a getInitParameter method.E、The foo parameter must be defined within the  element of the deployment descriptor.

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.

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?()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.

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

单选题Click the Exhibit button. Which statement is true about the classes and interfaces in the exhibit?()A Compilation will succeed for all classes and interfaces.B Compilation of class C will fail because of an error in line 2.C Compilation of class C will fail because of an error in line 6.D Compilation of class AImpl will fail because of an error in line 2.

单选题public class Person {  private name;  public Person(String name) {  this.name = name;  }  public int hashCode() {  return 420;  }  }  Which is true?()A The time to find the value from HashMap with a Person key depends on the size of the map.B Deleting a Person key from a HashMap will delete all map entries for all keys of typePerson.C Inserting a second Person object into a HashSet will cause the first Person object to beremoved as a duplicate.D The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.

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

单选题11. public static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? ()A 42B An exception is thrown at runtime.C Compilation fails because of an error on line 12.D Compilation fails because of an error on line 16.E Compilation fails because of an error on line 17.

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

单选题Given: What is the result when method testIfA is invoked?()A TrueB Not trueC An exception is thrown at runtime.D Compilation fails because of an error at line 12.E Compilation fails because of an error at line 19.

单选题Because of a logical corruption in your production database, you wanted to perform Tablespace Point in Time Recovery (TSPITR). But before you start the recovery, you queried the TS_PITR_OBJECTS_TO_BE_DROPPED view and realized that there are a large number of objects that would be dropped when you start the recovery by using this method.You want to preserve these objects. Which option must you use to perform TSPITR and preserve the object?()APerform Export before TSPITR and Import after TSPITRBMove objects to another schema that has the same tablespace assignedCPerform Incomplete Recovery before TSPITR with the Log Sequence Number (LSN)DPerform Incomplete Recovery before TSPITR with the System Change Number (SCN)

单选题Given: What is the result?()A The code runs with no output.B An exception is thrown at runtime.C Compilation fails because of an error in line 20.D Compilation fails because of an error in line 21.E Compilation fails because of an error in line 23.F Compilation fails because of an error in line 25.

单选题Given: What is the result?()A BB The code runs with no output.C Compilation fails because of an error in line 12.D Compilation fails because of an error in line 15.E Compilation fails because of an error in line 18.

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

单选题You are implementing an ASP.NET application. The application includes a Person class with property Age. You add a page in which you get a list of Person objects and display the objects in a GridView control. You need to add code so that the GridView row is highlighted in red if the age of the person is less than 18. Which GridView event should you handle?()ARowDataBoundBRowCommandCRowUpdatedDRowEditing