Multiple choice technology programming languages

You are considering four different "if" statements for the following code: public class IsItSame { public static void main(String [] args ) { int TheAnswer = 0; IsItSame x = new IsItSame(); Object y = x; IsItSame z = new IsItSame(); if (z == x) TheAnswer = 0; if (y == x) TheAnswer = 1; if (y == z) TheAnswer = 2; if (y.equals(z) ) TheAnswer = 3: if (x.equals(z) ) TheAnswer = 4; if (z.equals(y) ) TheAnswer = 5; System.out.printIn("The answer is " + TheAnswer); } } What will be printed out once the code is compiled and executed?

    1. The answer is 0
    1. The answer is 1
    1. The answer is 2
    1. The answer is 3
    1. The answer is 4
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In this code, z == x is false (different object instances), y == x is true (same reference), y == z is false. The equals() calls are misleading - Object's default equals() checks reference equality, so y.equals(z) is false, x.equals(z) is false, z.equals(y) is false. Thus, only TheAnswer = 1 executes, printing 'The answer is 1'.