Interview Questions

What is the use of Initialization and Finalization sections of Delphi?

Delphi Interview Questions


(Continued from previous question...)

What is the use of Initialization and Finalization sections of Delphi?

An1:
Every delphi unit(pas file) you can have Initialization and Finalization section which will be executed during unit load and unlond respectively

Unit2.pas
unit Unit2;
interface
uses
implementation
Initialization
//Do your Initialization Steps Here
Finalization
//Do your Finalization Steps Here
end.



An2:
The initialization section is optional. It begins with the reserved word initialization and continues until the beginning of the finalization section or, if there is no finalization section, until the end of the unit. The initialization section contains statements that are executed, in the order in which they appear, on program start-up. So, for example, if you have defined data structures that need to be initialized, you can do this in the initialization section.

(Continued on next question...)

Other Interview Questions