Yes, it is eventually garbage-collected when no references point to it. If something still points to it, no, e.g.
String s = "bar";
String s2 = s;
s = s.replace("r", "z");
Now s = “baz”, while s2 = “bar” (the original String object, which still has a reference pointing to it, and won’t be garbage-collected).