Qtr No. 213, New Town Yehlanka Indore 454775
Given:
public class Thing {
private String name;
public Thing(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
and
public class Tester {
public static void main(String[] args) {
Thing[] things = processThings();
/* line 1 */
for (Thing t : things) {
System.out.println(t);
}
}
public static Thing[] processThings() {
Thing[] things = new Thing[3];
things[0] = new Thing("Hat");
things[1] = new Thing("Rat");
things[2] = things[0];
things[0] = new Thing("Cat");
things[1] = things[2];
return things;
}
}
How many Thing objects are eligible for garbage collection in line 1?
3
1
2
0
To get all Infosys Certified Java SE11 Developer Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in