'TObject vs String casting there and back

Please someone explain me how can it works? TObject and String are incompatible, it shouldn't work, I thought.

var
  xObj: TObject;
begin
  // xObj := TObject('yyy'); // invalid typecast
  xObj := TObject('yyy ' + ClassName); // no error
  ShowMessage(String(xObj)); // no error too
end;

Also I'm curious when the xObj's memory gonna be freed?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source