Delphi MCQs

Delphi MCQs

Our experts have gathered these Delphi MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of Delphi by answering these 40 multiple-choice questions.
Get started now by scrolling down!


Which of the following are the valid DeviceType property values for the TMediaPlayer component?

A.   dtAutoSelect

B.   dtMP3

C.   dtExternalDevice

D.   dtAudio

E.   dtTV

F.   dtMPEG3

G.   dtDAT

H.   dtDigitalVideo


Which of the following are valid identifier names for a variable?

A.   Cust_no5

B.   Cust no5

C.   5Cust_No

D.   cUSTNo

E.   cUSTNo

F.   cust&no


TDataSet is a base class from which other database components are inherited to encapsulate which database object(s)?

A.   A Table

B.   A Trigger

C.   A Field

D.   A Query

E.   A DBAware Component

F.   A Stored Procedure


Which of the following will add text to a TMemo component called Memo1?

A.   Memo1.Lines.Add('Text');

B.   Memo1.AddLine('Text');

C.   Memo1.Lines.Include('Text');

D.   Memo1.Lines.Append('Text');

A.   TTable

B.   TDataSource

C.   TMasterDetail

D.   TDatabase

A.   UpDown1.Associate := Edit1;

B.   UpDown1.Link := Edit1;

C.   UpDown1.Link(Edit1);

D.   Link(UpDown1,Edit1);


What is the purpose of the "Break" procedure?

A.   It causes the flow of control to exit the current function or procedure and execute the next logical code statement

B.   It causes the current thread to suspend execution to allow other threads to operate

C.   It simulates the user pressing the Break key on the keyboard

D.   It causes the flow of control to exit a loop and continue at the next statement following the loop


For a TQuery component called Query1 with SQL of "Select * from Student Where Number=500", which of the following is the correct method to run the query?

A.   Query1.Active:=True;

B.   Query1.RunSQL;

C.   Query1.ExecuteAction(SQL);

D.   Query1.ExecSQL;


What does the Cancel property of the TButton object do?

A.   It automatically displays Cancel as the button caption

B.   It determines if the button's OnClick event handler is called when the Escape key <Esc> is pressed on the keyboard

C.   It calls the parent forms' OnClose event

D.   It causes a popup menu to be displayed when the button is clicked which permits the user to select Cancel


Which property of TBitBtn allows you to specify what image to display on the button?

A.   BitBtn1.CaptionImage

B.   BitBtn1.Image

C.   BitBtn1.Glyph

D.   BitBtn1.Picture


What is the value of the variable int_temp after the for loop has ended in the code shown?

A.   1

B.   2

C.   5

D.   The value of int_temp is undefined


Which of the following will connect a DataSource to a Table where the Datasource component is call DataSource1 and the Table component is called Table1?

A.   DataSource1.Table:=Table1;

B.   DataSource1.DataSet:=Table1;

C.   DataSource1.Source:=Table1;

D.   DataSource1.SetTable(Table1);


Which of the following is a event of TPanel?

A.   OnClose

B.   OnExit

C.   OnTerminate

D.   OnDoubleClick


Given the code "Edit1.Hint := 'Customer Name|Enter Customer Name in the edit box';", which of the following is the correct code to retrieve the text after the | character, i.e. "Enter Customer Name in the edit box", when the OnHint handler is called?

A.   GetLongHint(Application.Hint);

B.   GetHint(Application.Hint);

C.   GetShortHint(Application.Hint);

D.   GetSecondHint(Application.Hint);


Which three properties of TProgressBar are responsible for setting the minimum, maximum and current position for the control?

A.   Maximum, Minimum & Percentage

B.   Maximum, Minimum & Position

C.   Max, Min & Position

D.   Max, Min & Pos


What happens if the TreeView1.Items list is empty when the code "TreeView1.Items.AddFirst(TreeView1.Items[0],'X');" is executed?

A.   An X appears as the top most node in the TreeView

B.   An "Index is out of bounds" error message is displayed

C.   An ETreeViewError exception is raised with the message 'Invalid Index'

D.   An X appears as a sub node to the first node in the TreeView


Given that x and y are variables declared as type Char, which of the following is NOT a valid Pascal assignment statement?

A.   x := y;

B.   x := Char(Ord(Y)+1);

C.   x := Char(#22);

D.   x := y + #22;


How does a TRichEdit differ from a TMemo?

A.   TRichEdit prevents users from overwriting existing text, whereas TMemo does not

B.   TRichEdit allows saving directly to text files, whereas TMemo does not

C.   TRichEdit prevents font attributes from being changed by the user, whereas TMemo does not

D.   TRichEdit allows font attributes to be set, whereas TMemo does not


Which of the following is the correct method to activate a modal open dialog box when using the TOpenDialog component?

A.   OpenDialog1.OpenFile;

B.   OpenDialog1.GetFile;

C.   OpenDialog1.Filename;

D.   OpenDialog1.Execute;


Which of the following is the correct code to create an object from class TMainForm?

A.   Form.Create(TMainForm);

B.   Application.CreateForm(TMainForm, MainForm);

C.   TMainForm.CreateForm(MainForm);

D.   MainForm:=Application.CreateFormInstance(TMainForm);


What files end with the .dpk extension?

A.   Unit Source files

B.   Project Source files

C.   Package Source files

D.   Delphi Library


What is the main difference between TLabel and TStaticText?

A.   TStaticText has a Window Handle and can accept focus whereas TLabel does not have a Window Handle and cannot accept focus

B.   TStaticText allows the user to edit the text displayed whereas TLabel does not allow the user to edit the text displayed

C.   TLabel's caption property can be changed programmatically whereas TStaticText's Caption property cannot be changed programmatically

D.   TLabel does not have a ShowAccelChar property whereas TStaticText does have a ShowAccelChar property


Which of the following changes a TDBNavigator component called DBNavigator1 so that it only displays navigation buttons?

A.   DBNavigator1.VisibleButtons := [nbFirst,nbLast,nbPrior,nbNext];

B.   DBNavigator1.NavigationOnly := True;

C.   DBNavigator1.Buttons := [nbFirst,nbLast,nbPrior,nbNext];

D.   DBNavigator1.Constraints := [nbFirst,nbLast,nbPrior,nbNext];


What value is displayed on screen when the procedure test is called?

A.   5

B.   13

C.   8

D.   3


What is the purpose of the Alignment Palette?

A.   To change the order or position of the components in the Visual Component Library

B.   To align the main IDE Windows to each other

C.   To align components to the form, or with each other

D.   To set the alignment property of any components on a form


Which of the following would cause all the items in a RadioGroup to be appended so that all items appear twice?

A.   Radiogroup1.Items.Duplicate;

B.   Radiogroup1.Append(Radiogroup1);

C.   Radiogroup1.Items.Append(rgALL);

D.   Radiogroup1.Items.AddStrings(Radiogroup1.Items);


Which of the following is the correct code to cause a form named Form1 to be displayed as modal?

A.   Form1.Show;

B.   ShowModal(Form1);

C.   Form1.ModalResult:=mrOk

D.   Form1.ShowModal;


Which of the following is the correct code to "tick" a TCheckBox component called CheckBox1 as shown?

A.   CheckBox1.Checked:=True;

B.   CheckBox1.Ticked:=True;

C.   CheckBox1.Tick(True);

D.   CheckBox1.Enabled:=True;


What does the TDBLookupComboBox component do?

A.   It allows a field value to be selected from a TList object specified by the programmer

B.   It performs a search for a field with the same name as the text entered

C.   It allows the selection of a database from a list of those found on a network

D.   It identifies a set of field values in one dataset with a corresponding set of values from another dataset


In the code shown, TMyClass inherits from which parent class?

A.   TApplication

B.   TObject

C.   Inheritance does not take place

D.   TMyClass


Which of the following removes the SQL statement from a TQuery component called Query1?

A.   Query1.SQL.Delete;

B.   Query1.Delete(SQL

C.   Query1.SQL.Clear;

D.   Query1.Enabled:=False;


Which of the following is NOT an event of the TApplicationEvents component?

A.   OnActionExecute

B.   OnBusy

C.   OnMessage

D.   OnHint

E.   OnException

F.   OnSettingChange


When will the code "Application.Terminate;" be executed in the code shown?

A.   When the user presses the Cancel button

B.   Every time the procedure is executed

C.   When the user presses the Ok button

D.   Never


What is the purpose of the AutoMerge property in the TMainMenu component?

A.   It determines if main menus of secondary forms merge with the main menu of the main form in non-MDI applications at runtime

B.   It determines if sub menu items are automatically merged with the parent menu items if there is only a single sub menu item

C.   It determines if the main menu items can be automatically resized at runtime so that they provide a "best fit" in a resizable form

D.   It determines if the TMainMenu component can correct menu item short cut key conflicts with existing Windows short cut keys


What is the shortcut key for manually displaying the code completion window while entering code?




D.   CTRL + Page Down


The TTimer component has a property which determines how frequently the OnTimer event occurs.  Which of the following is that property and what does the property measure?

A.   Property: Time, Measured in: Seconds

B.   Property: Timer, Measured in: Hundreds of a second (1/100 Sec)

C.   Property: Interval, Measured in: Milliseconds (1/1000 Sec)

D.   Property: Tick, Measured in: Clock Ticks


Given a ComboBox named ComboBox1 and an Edit box named Edit1, which of the following is the correct code to add the information in the Edit box to the drop down list in the ComboBox?

A.   ComboBox1.Items.Add(Edit1.Text);

B.   ComboBox1.Strings := ComboBox1.Strings + Edit1.Text;

C.   ComboBox1.List.AddItem(Edit1.Text);

D.   ComboBox1.Append(Edit1.Text);


Which of the following properties when set to True, enables an application to gain sole access to a database?

A.   TDatabase.OthersReadOnly

B.   TDatabase.KeepConnection

C.   TDatabase.Params

D.   TDatabase.Exclusive


What is the purpose of Code Templates?

A.   To provide easy access to commonly used programming statements

B.   To allow the creation of Document Templates from existing source code

C.   To provide easy access to Native Databases without using components

D.   To allow the conversion of selected code to a procedure


What does the procedure shown do?

A.   It moves the contents of the file c:\autoexec.bat to the file c:\outfile.txt

B.   It moves the contents of the file c:\outfile.txt to the file c:\autoexec.bat

C.   It copies the contents of the file c:\autoexec.bat to the file c:\outfile.txt

D.   It copies the contents of the file c:\outfile.txt to the file c:\autoexec.bat


What is the purpose of the TDataModule?

A.   To provide a login to a secured or an encrypted database

B.   To provide a temporary storage area of query results

C.   To provide a location for centralized handling of non-visual components

D.   To provide a connection to a remote database server


What is the purpose of the AlphaBlend property of TForm?

A.   It specifies the background color of the form

B.   It specifies if the form is translucent or not

C.   It specifies if the form is available for drawing on via TCanvas

D.   It specifies the redrawing speed of the form


What is the purpose of the Initialization section of a Unit?

A.   It contains assembly code that is executed on PC startup

B.   It contains statements that are executed on unit start up

C.   It contains Window handling code

D.   It contains program management code and should not be edited directly by a programmer


Which key toggles between the Object Inspector and the Edit Window / Form?

A.   ALT + O

B.   F11

C.   F4



Given a TPageControl component called PageControl1 with three TabSheets called TabSheet1, TabSheet2 and TabSheet3 (in that order), which of the following will make TabSheet2 selected?

A.   PageControl1.TabIndex:=1;

B.   TabSheet2.Show;

C.   PageControl1.ShowTab(TabSheet2);

D.   PageControl1.VisibleTab:=TabSheet2;

E.   TabSheet2.Click;

F.   TabSheet2.Select(PageControl1);


Which of the following is the correct code to cause a popup menu named Popupmenu1 on a form called Form1 to be displayed?

A.   Application.DisplayMenu(Form1.Popupmenu1);

B.   Form1.Popupmenu1.Popup(20,30);

C.   Form1.Popupmenu1.ShowMenu;

D.   Form1.ShowMenu(Popupmenu1);


Which of the following retrieves the value from the SNumber field as a string for the current record in an open Table called Table1?

A.   Table1.Field.SNumber.AsString;

B.   String(Table1.Fields('SNumber'));

C.   Table1.FieldByName('SNumber').AsString;

D.   Table1.Items.String('SNumber');


 This question is based upon the figure shown below

From the code shown, how many times would the ShowMessage procedure be called if the button in question was clicked three (3) times?


A.   1

B.   2

C.   3