IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Study Test
PRESTWOODCERTIFIED
Delphi Study Test◄╣
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

November Edition
Subscribe now! It's Free!
Enter your email:

   ► Prestwood Certified   Print This    All Groups  
Printable Version Print Answers

Delphi Study Test

Practice tests to further your career.

Intro

The following study test contains practice certification questions along with a study link for each question.  These questions were prepared by Mike Prestwood and are intended to stress an important aspect. All our practice questions are intended to prepare you specifically to earn your Prestwood certification and generally for passing any certification test as well as prepare you for professional work.

Features:

  • Each question has a popup [Review] link.
  • Hover over answers to reveal correct answer.

24 Questions


Mouse over answers to reveal correct answer.

Beginner

15 Beginner Level Questions

Question #1: True or False?

You can add single line comments to your code using // and multiple line comments using either { } or (* *).

Answer:
  • True
  • False
  • Question #2: True or False?

    In Delphi you can declare and make use of same named-different case variables (two distinct variables) as in the following:

    MyName : String;
    MYNAME : String;
    Answer:
  • True
  • False
  • Question #3: Multiple Choice

    Which example uses the correct syntax to declare a constant?

    Answer:
    1. 

    const
      kPI : Double := 3.1459;

    2. 


    const
      kPI Double := 3.1459;


    3. 


    const
      kPI Double = 3.1459;


    4. 

    const
      kPI : Double = 3.1459;

    5. 

    const
      kPI As Double := 3.1459;


    Question #4: True or False?

    VB.Net compiles to true Win32 native code applications that do not require the .Net framework.

    Answer:
  • True
  • False
  • Question #5: Multiple Choice

    The correct syntax for a declaritive variable assignment is?

    Answer:
    1. 
    Dim Married As String = "N"
    2. 
    Married String := 'N';
    3. 
    Married : String := 'N';
    4. 
    Married : String = 'N';
    5. 
    String Married = "N";
    Question #6: Multiple Choice

    Which code line correctly embeds an apostrophe?

    Answer:
    1. 
    ShowMessage('Hello Mike''s website.');
    2. 
    ShowMessage('Hello Mike\'s website.');
    3. 
    ShowMessage("Hello Mike's website.");
    4. 
    ShowMessage('Hello Mike#'s website.');
    5. 
    ShowMessage('Hello Mike'''s website.');
    Question #7: Yes or No?

    If x is defined as a variable of type double, will the following compile?

    x := .1 + .1;
    Answer:
  • Yes
  • No
  • Question #8: Multiple Choice

    Given the following code:

    var
    MyObject: TObject;
    begin
    MyObject := TObject.Create;
     
      //Use it...  
    end;
    Answer:
    1. 

    Delphi does not have a garbage collector so you have to dispose of the object after the "Use it" comment with either MyObject.Free() or FreeAndNil(MyObject).

    2. 

    Delphi has a garbage collector so you do not have to dispose of the object after the "Use it" comment but optionally you can dispose of additional resources created in the constructure overriding the Finalize() method and calling MyObject.Free().

    3. 

    Delphi does not have a garbage collector so you have to dispose of the object after the "Use it" comment with MyObject.Dispose().

    Question #9: True or False?

    The default for parameters for procedures, functions, and methods is by value.

    Answer:
  • True
  • False
  • Question #10: True or False?

    Delphi uses the keyword Overridable to define a virtual method in a parent class and the keyword Overrides to replace the method in a descendant class.

    Answer:
  • True
  • False
  • Question #11: True or False?

    Given the following code, which ShowMessage will display? The True or the False one?

    var
      a, b, c, d: Boolean;
    begin
      a := True;
      b := True;
      c := True;
      d := True;
      
      if Not (a and b) and (c or d) then
        ShowMessage('True')
      else
        ShowMessage('False');
    end;
    Answer:
  • True
  • False
  • Question #12: Multiple Choice

    The class visibility specifiers are:

    Answer:
    1. 

    private, protected, public, and published.

    2. 

    private, protected, and public.

    3. 

    private, strict private, protected, stict protected, public, and published.

    4. 

    private, protected, assembly and protected, assembly or protected, and public.

    5. 

    private, protected, internal, protected internal, and public.

    Question #13: Multiple Choice

    Given this class:

    TPerson = class(TObject)
    end; 

    Which of the following is the correct syntax for creating an object instance from a class?

    Answer:
    1. 

    Declare a variable:

    var
      Lisa: TPerson;

    Create instance:

    Lisa := TPerson.Create; 
    2. 

    Declare a variable:

    var
      Lisa: TPerson;

    Create instance:

    TPerson Lisa := TPerson.Create; 
    3. 

    Declare a variable:

    var
      Lisa: TPerson;

    Create instance:

    Lisa := Person.Create; 
    4. 

    Declare a variable:

    var
      Lisa: TPerson;

    Create instance:

    Lisa := New TPerson; 
    5. 

    Declare a variable:

    var
      Lisa TPerson;

    Create instance:

    Lisa = TPerson.Create; 
    Question #14: Multiple Choice

    Which of the following lines of code will compile?

    Answer:
    1. 
    WriteLn('Hello');  WriteLn(' world');
    2. 
    WriteLn
      (
      'hello'
      );
    3. 
    WriteLn
      ('Hello');
    4. 

    All of the above.

    5. 

    None of the above.

    Question #15: Multiple Choice

    Which is the correct syntax for declaring an array and setting two values of the array?

    Answer:
    1. 
    Dim MyArray As Variant
    MyArray = Array("Mike", "Lisa")
    2. 
    var
      MyArray: array[0..3] of string;
    begin
      MyArray[0] := 'Mike';
      MyArray[1] := 'Lisa';
    end;
    3. 
    var
      MyArray Array[2] String
    endVar
    MyArray[1] = "Mike"
    MyArray[2] = "Lisa"
    4. 
    var
      MyArray: array[0..3] of string;
    begin
      MyArray(0) = 'Mike';
      MyArray(1) = 'Lisa';
    end;
    5. 
    var
      MyArray array(0..3) : string;
    begin
      MyArray[0] := 'Mike';
      MyArray[1] := 'Lisa';
    end;

    Intermediate

    6 Intermediate Level Questions

    Question #16: Multiple Choice

    Which is the correct syntax for declaring and using a set?

    Answer:
    1. 


    var
      ValidStrings: Set Char;  
    begin
    ValidStrings := ['Y', 'N', 'X']; 
      
    If 'Y' in ValidStrings then
      ShowMessage('Yes, Y is valid');
      
    end;


    2. 

    var
      ValidStrings: Set of Char;  
    begin
    ValidStrings := ['Y', 'N', 'X']; 
      
    If 'Y' in ValidStrings then
      ShowMessage('Yes, Y is valid');
      
    end;

    3. 


    var
      ValidStrings: Set Char;  
    begin
    ValidStrings := ('Y', 'N', 'X'); 
      
    If 'Y' in ValidStrings then
      ShowMessage('Yes, Y is valid');
      
    end;


    4. 


    var
      ValidStrings: ArraySet of Char;  
    begin
    ValidStrings := ('Y', 'N', 'X'); 
      
    If 'Y' in ValidStrings then
      ShowMessage('Yes, Y is valid');
      
    end;


    5. 


    var
      ValidStrings: ArraySet Char;  
    begin
    ValidStrings := ['Y', 'N', 'X']; 
      
    If 'Y' in ValidStrings then
      ShowMessage('Yes, Y is valid');
      
    end;


    Question #17: Multiple Choice

    What does the following line of code do?

    {$APPTYPE CONSOLE}
    Answer:
    1. 

    This is a comment so it does nothing.

    2. 

    The {$ } indicates this comment is actually a compiler directive. The $APPTYPE compiler directive is used in the project source file (.DPR) to tell the compiler what type of application to compile. In this case, a DOS-like console application. When left out, the default is {$APPTYPE GUI} which is a Windows forms based application.

    3. 

    This code will give you an error.

    4. 

    The {$ } indicates this comment is actually a compiler directive. The $APPTYPE compiler directive is used in the project source file (.DPR) to tell the compiler what type of application to compile. In this case, a Windows forms based application. When left out, the default is a DOS-like command application.

    5. 

    The {$ } indicates this comment is actually a compiler directive. The $APPTYPE compiler directive is used in the project source file (.DPR) to tell the compiler what type of application to compile. In this case, a Windows DLL. When left out, the default is a DOS-like command application.

    Question #18: Multiple Choice

    Given the following three code snippets:

    1. TPerson = class(TObject)
    end;
     
    2. TPerson = class
    end;
      
    3. TPerson = class(System.TObject)
    end;

    Which of the following statement is most accurate?

    Answer:
    1. 

    1 and 3 are equivalent, 2 will not even compile.

    2. 

    All three are equivalent.

    3. 

    2 and 3 are equivalent, 1 will not even compile.

    4. 

    1 and 2 are equivalent, 3 will not even compile.

    Question #19: True or False?

    A single class can inherit from a parent class and implement one "or more" interfaces.

    Answer:
  • True
  • False
  • Question #20: Multiple Choice

    The method name of a constructor is?

    Answer:
    1. 

    Not defined, use the constructor keyword to signify which method or methods are constructors for a class.

    2. 

    Create

    3. 

    New

    4. 

    Same name as the class.

    5. 

    ~ + class name, i.e. ~Person

    Question #21: True or False?

    The method name for a class constructor can be anything including Create and CreateFromTable.

    Answer:
  • True
  • False

  • Advanced

    3 Advanced Level Questions

    Question #22: Multiple Choice

    The correct syntax to inline a function is...

    Answer:
    1. 
    function DoSomething; __forceinline;
    begin
    end;
    2. 
    _inline function DoSomething;
    begin
    end;
    3. 
    function DoSomething; inline;
    begin
    end;
    4. 

    All of the above.

    5. 

    None of the above. Delphi does not support inlining even in later versions of Delphi such as Delphi 2005 and above.

    Question #23: Multiple Choice

    In later versions of Delphi, you prevent class and method inheritance with what keyword(s)?

    Answer:
    1. 

    You prevent derivation with the final keyword for classes and the sealed keyword for methods.

    type
      Robot = class final(TObject)
    public
      procedure x(); virtual; sealed;
    end;
    2. 

    You prevent derivation for classes and methods using the sealed keyword.

    type
      Robot = class sealed(TObject)
    public
      procedure x(); virtual; sealed;
    end;
    3. 

    You prevent derivation for classes and methods using the final keyword.

    type
      Robot = class final(TObject)
    public
      procedure x(); virtual; final;
    end;
    4. 

    Delphi for Win32 does not support preventing of inheritance with any version of Delphi including later versions.

    5. 

    You prevent derivation with the sealed keyword for classes and the final keyword for methods.

    type
      Robot = class sealed(TObject)
    public
      procedure x(); virtual; final;
    end;
    Question #24: Yes or No?

    Will the following code compile?

    TObjectHelper = class helper for TObject
    strict private
      FTempStr: String;
    public
      property TempStr: String
    read FTempStr write FTempStr;
    end;
    Answer:
  • Yes
  • No
  • Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
    www.prestwood.com


    ©1995-2024 Prestwood IT Solutions.   [Security & Privacy]