The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.