¡GoConqr estrena diseño! Cuéntanos qué te parece.

Test

Comparing objects for equality

alim586 3 preguntas

Hacer el test

Preguntas del test (3)

  1. 1The default implementation of the equal method compares only whether two object variables refer to the same object
    1. AVerdadero
    2. BFalso
  2. 2See 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?
    1. AVerdadero
    2. BFalso
  3. 3Why is the next equals method in conflict with the contract for the equals method

    public boolean equals (Object anObject){
    return true;
    }
    1. ABecause it returns true, even for null values passed to this method
    2. BBecause it doesn't compare the values of the instance variables of the objects
    3. CBoth answers are true

Información

Descripción
Test sobre Comparing objects for equality, creado por alim586 el 20/06/2015.
Autor
alim586
Idioma
English
Visitas
21
Valoración
Aún sin valoraciones
Valora este test
Valora este test

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?