alim586
Test por , creado hace más de 1 año

Test sobre Comparing objects for equality, creado por alim586 el 20/06/2015.

7
0
0
alim586
Creado por alim586 hace más de 9 años
Cerrar

Comparing objects for equality

Pregunta 1 de 3

1

The default implementation of the equal method compares only whether two object variables refer to the same object

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 2 de 3

1

See the following equals method defined in class BankAccount.

class BankAccount(){

String accNumber;
int accType;

public boolean equals (Object obj){
if(obj instanceOf BankAccount){
BankAccount b = (BankAccount) obje;
return(acctumber.equals(b.accNumber) && accType == b.accType);
}
return false;
}
}
Does this method violates the contract for the equals method?

Selecciona uno de los siguientes:

  • VERDADERO
  • FALSO

Explicación

Pregunta 3 de 3

1

Why is the next equals method in conflict with the contract for the equals method

public boolean equals (Object anObject){
return true;
}

Selecciona una de las siguientes respuestas posibles:

  • Because it returns true, even for null values passed to this method

  • Because it doesn't compare the values of the instance variables of the objects

  • Both answers are true

Explicación