Oracle
1Z0-819 · Question #197
1Z0-819 Question #197: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #197. The question stem and answer options stay visible for context.
Question
How many Thing objects are eligible for garbage collection in line 1? ```java
private String name;
public Thing(String name) {
this.name = name;
}
public String toString() {
return name;
}
public class Tester {
public static void main(String[] args) {
List<Thing> things = new ArrayList<>();
for (int i=0; i<5; i++) {
things.add(new Thing("Thing" + i));
}
System.out.println(things);
}
public static Thing[] processThings() {
Thing[] things = new Thing[3];
things[0] = new Thing("Rat");
things[1] = new Thing("Cat");
things[2] = things[0]; // Line 1
things[0] = new Thing("Dog");
things[1] = things[2];
return things;
}
}
Options
- A0
- B2
- C0
- D4
- E3
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.