Objective-c Quiz: Categories And Protocols

11 Questions | Attempts: 1606
Share

SettingsSettingsSettings
Objective-c Quiz: Categories And Protocols - Quiz

Objective-C Quiz: Categories and Protocols


Questions and Answers
  • 1. 
    A category can be used to add new instance variables to a class.
    • A. 

      TRUE

    • B. 

      FALSE

  • 2. 
    The lineid <Painting> myObject;
    • A. 

      Says that myObject is part of the Painting category

    • B. 

      Says that myObject conforms to the Painting category

    • C. 

      Says that myObject conforms to the Painting protocol

    • D. 

      Is not valid Objective-C syntax

  • 3. 
    The conformsToProtocol: method can be used to see if an object belongs to a class that implements a particular protocol
    • A. 

      TRUE

    • B. 

      FALSE

  • 4. 
    A category can be used to override other methods in the class, but it's not considered good programming practice.
    • A. 

      TRUE

    • B. 

      FALSE

  • 5. 
    The [email protected] GObj: NSObject <Painting>
    • A. 

      Starts the definition of a Painting category

    • B. 

      Starts the definition of a Painting protocol

    • C. 

      Painting protocol

    • D. 

      Starts the definition of a class called GObj that conforms to the

    • E. 

      None of the above

  • 6. 
    You could add a category to theNSString class, for example, to extend its functionality.
    • A. 

      TRUE

    • B. 

      FALSE

  • 7. 
    The following:@interface Fraction (MathOps)  [email protected]
    • A. 

      Defines a category called MathOps

    • B. 

      Defines a protocol called MathOps

  • 8. 
    If you start a class definition that conforms to a specified protocol, you need to relist all the methods you will implement for that protocol in the @interface section.
    • A. 

      TRUE

    • B. 

      FALSE

  • 9. 
    A category can be used to add new instance variables to a class.
    • A. 

      TRUE

    • B. 

      FALSE

  • 10. 
    All of the methods in a category must be implemented
    • A. 

      TRUE

    • B. 

      FALSE

  • 11. 
    A category can be a good way to divide the implementation of a class into logical sections
    • A. 

      TRUE

    • B. 

      FALSE

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.