Boa noite pessoal,
estou estudando um pouco aqui para a certificação OCJA que irei prestar dentro de uma semana e a seguinte questão me causou confusão onde a resposta correta é a D.
Alguem poderia me informar o motivo ? realmente tentei descobrir mas não obtive sucesso.
Agradeço imensamente a ajuda.
Segue a questão:
Given the following implementation of the Car class:
public class Car extends Object{
String model;
public Car(String m) {model = m;}
}
What would be the result of running the following code?
Car myCar = new Car(“Silver Z3”);
Car stolenCar = new Car(“Silver Z3”);
if (myCar.equals(stolenCar)) {
System.out.println(“look at that pretty car.”);
}
if (myCar == stolenCar) {
System.out.println(“SOMEBODY HAS STOLEN MY ******* CAR!!!”);
}
A) look at that pretty car
B) SOMEBODY HAS STOLEN MY ******* CAR!!!
C) look at that pretty car SOMEBODY HAS STOLEN MY ******* CAR!!!
D) there will be no output