I am working on the OCA Java certification and unsure of how to understand the answer to one question.
public class Test {
public static void main(String[] args){
Student s1 = new Student("o1");
Student s2 = new Student("o2");
Student s3 = new Student("o3");
s1=s3;
s3=s2;
s2=null;
//HERE
}
}
The question is which object will be available for garbage collection after the //HERE point.
The answer provided by the online test is : One object (o1).
Can someone explain me why?