With this code, what will happen:

program FunWithDelphi;

{$APPTYPE CONSOLE}

uses
  Controls, SysUtils;

begin
  try
    raise TMouse.Create;
  except
    on E:Exception do
    begin
      Writeln(E.Classname, ': E is Exception');
    end;
    on E:TObject do
    begin
      Writeln(E.Classname, ': E is TObject');
    end;
    on E:TMouse do
    begin
      Writeln(E.Classname, ': E is TMouse');
    end;
  end;
  ReadLn;
end.
  • the program will print “TMouse: E is Exception”
  • the program will print “TMouse: E is TObject”
  • the program will print “TMouse: E is TMouse”
  • compilation fails
  • the program will terminate with a runtime error

Correct answer: the program will print “TMouse: E is TObject”
(Tested with Delphi 2009)


Discover more from Habarisoft Blog

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *