Objective-c Coding Test

10 Questions | Total Attempts: 539

SettingsSettingsSettings
Objective-c Coding Test

Objective-C is a general-purpose, object-oriented programming language derived from the C programming language. It was the main programming language used by Apple for their OS X and iOS operating systems prior to the introduction of SWIFT. After all that history, I am sure you will want to know more about this programming language. Find out how much you know by attempting this quiz.


Questions and Answers
  • 1. 
    What is the file extension name used for Objective-C code?
    • A. 

      .c

    • B. 

      .pl

    • C. 

      .m

    • D. 

      .cpp

  • 2. 
    What does the leading + sign at the start of a method indicate?
    • A. 

      An instance method

    • B. 

      A class method

    • C. 

      An initialization method

    • D. 

      None of the above

  • 3. 
    What is the value of s after executing this loop: int i = 0, s = 0; while (i < 5)    s += ++i;
    • A. 

      16

    • B. 

      15

    • C. 

      14

    • D. 

      11

  • 4. 
    What is the value of z after executing this sequence (check indentation)? int x = 100, y = 50, z = -1; if ( x + y > 50)    if ( x + y < 100)       z = 0; else    z = 1;
    • A. 

      -1

    • B. 

      0

    • C. 

      1

    • D. 

      This problem is too hard!

  • 5. 
    What is a local variable that has no default initial value and does not retain its value through method calls?
    • A. 

      A static variable

    • B. 

      An auto variable

    • C. 

      A global variable

    • D. 

      None of the above

  • 6. 
    What is wrong with this sequence of code? sum = 100; int sum;
    • A. 

      "sum" is a reserved word

    • B. 

      A variable must be declared before it can be used

    • C. 

      Nothing is wrong

    • D. 

      Everything is wrong! I hate Objective-C!

  • 7. 
    Given int a = 10, b = 20, c; b *= a + 5; What is the resulting value of b?
    • A. 

      205

    • B. 

      200

    • C. 

      300

    • D. 

      The statement will generate a compiler error

  • 8. 
    Which is an example of an invalid variable name?
    • A. 

      Floats

    • B. 

      X123$

    • C. 

      Two_By_Four

    • D. 

      _Rectangle

  • 9. 
    What should you do If you want to return an object back to the caller of your method and you want to mark the object for a later release?
    • A. 

      Autorelease it before returning

    • B. 

      Copy it before returning

    • C. 

      Release it before returning

    • D. 

      Retain it before returning

  • 10. 
    Which value is not equivalent to the others?
    • A. 

      0x64

    • B. 

      0144

    • C. 

      100

    • D. 

      0XE5