logo

Crowdly

Dado el siguiente código en Java: public class Persona { private String nom...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Dado el siguiente código en Java:

public class Persona {

private String nombre;

Persona(String nombre) {

this.nombre = nombre;

}

public boolean equals(Object obj) {

if (this == obj) return true;

if (! obj instanceof Persona ) return false;

Persona otro = (Persona) obj;

return nombre.equals(otro.nombre);

}

}

public class TestPersona {

public static void main(String[] args) {

Persona p1 = new Persona("Carlos");

Persona p2 = new Persona("Carlos");

Persona p3 = p1;

System.out.print(p1.equals(p2) + “ “);

System.out.print((p1 == p2) + “ “);

System.out.print(p1 == p3);

}

}

¿Cuál será la salida en consola al ejecutar este código?

0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.upm.es?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!