Reference variables hq [0], hq [1], hq [2], hq [3], hq [4] and objects id = 0, id = 1, id = 2 are given. Which reference variables correspond to objects

class HeapQuiz { int id = 0; public static void main(String[] args) { int x = 0; HeapQuiz[] hq = new HeapQuiz[5]; while (x < 3){ hq[x] = new HeapQuiz(); hq[x].id = x; x++; } hq[3] = hq[1]; hq[4] = hq[1]; hq[3] = null; hq[4] = hq[0]; hq[0] = hq[3]; hq[3] = hq[2]; hq[2] = hq[0]; System.out.println(hq[x]); } } 
  • 3
    draw five cells and perform assignments on paper. That's not difficult. - Igor

1 answer 1

null, {id = 1}, null, {id = 2}, {id = 0}