SCJP程序员认证考试

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

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

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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.

正确答案:A

第2题:

Which of the following statements about variables and scope are true?() 

  • A、 Local variables defined inside a method are destroyed when the method is exited.
  • B、 Local variables are also called automatic variables.
  • C、 Variables defined outside a method are created when the object is constructed.
  • D、 A method parameter variable continues to exist for as long as the object is needed in which the method is defined.

正确答案:A,B,C

第3题:

Which of the following statements regarding routed and routing protocols are true?()

A. A routed protocol is assigned to an interface and determines the method of packet deliver.

B. A routing protocol determines the path of a packet through a network.

C. A routed protocol determines the path of a packet through a network.

D. A routing protocol operates at the transport layer of the OSI model.

E. A routed protocol updates the routing table of a router.


参考答案:A, B

第4题:

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.

正确答案:B

第5题:

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.

正确答案:A,D

第6题:

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.

正确答案:C,D

第7题:

Given that b and c refer to instances of wrapper classes, which two statements are true?()

  • A、 b.equals(b) returns true.
  • B、 b.equals(c) returns the same result as b == c.
  • C、 b.eqials(c) can return false even if c.equals(b) returns true.
  • D、 b.equals(c) throws an exception if b and c are different wrapper types.
  • E、 b.equals(c) returns false if the type of wrapper objects being compared are different.

正确答案:B,C

第8题:

Part of the job as a network administrator is being able to make a distinction between routed protocols and routing protocols. Which of the following statements is true regarding them?()

A. A routing protocol is assigned to an interface and determines the method of packet delivery.

B. A routed protocol is assigned to an interface and determines the method of packet delivery.

C. A routing protocol determines the path of a packet through a network.

D. A routed protocol determines the path of a packet through a network.

E. A routing protocol operates at the transport layer of the OSI model.

F. A routed protocol updates the routing table of a router.


参考答案:B, C

第9题:

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.

正确答案:A,C

第10题:

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.

正确答案:B,C

更多相关问题