I think the answer should be line 4, I will tell you why:
a points to "hello"
b points to "byte" //line 0
c points to "byte!" //line 1, notice that this is a new string
d points to b, which points to "byte" //line 2
b now points to a, which points to "hello" //line 3
notice that at this stage "byte" is still being pointed at by d
d now points to a, which points to "hello" //line 4
notice now that "byte" is not being pointed at by any other
variable. so it is available for GC
once the
Java Virtual Machine (JVM) finished with line 4, and
before it jump to line 5, it will mark "byte" to be eligible for
GC, remember that GC can start AT ANY TIME , no guarantee when
it will start, and this answers your second question , the JVM
does not wait for the method to finish to start its GC, because
if it does that, the method may take valuable memory location
that it does not really need.
GC got nothing to do with when the methods will be terminated.