Swift - Programming Language

Skill Test Set 7: Extensions, Protocols

  1. Which keyword do you use to define a protocol?

    protocol
    @interface
    @protocol
    Protocol

  2. Which is correct for Enumerations?
    Enumerations can define initializers.
    Enumerations cannot conform to protocols.
    Enumerations cannot conform to protocols.

  3. What is the type of Swift Enumerations?
    Reference type
    Class type
    Collection type
    Value type

  4. What keyword is used to indicate a custom operator that will appear in between two targets, similar to the addition operator in this example?
    var sum = 10 + 10
    @inter
    between
    infix
    @center

  5. To which of these type does ARC apply?
    Class
    Structure
    Enumeration
    Basic types (String, Int, Bool)

  6. Why are IBOutlets declared with a weak attribute by default?
    IBOutlets are not declared with a weak attribute by default
    To save memory
    To increase loading speed
    They are already retained by the view

  7. What does the retainCount specify in ARC?
    The current number of strong references to an object.
    The current number of instances of an object.
    The total number of objects currently being retained in memory.
    The total number of times an object has been allocated.

  8. How do closures capture references to variables by default?
    By weak reference.
    By strong reference.
    By unowned reference.
    By copy.

  9. Which keyword is used on a function inside an Enumeration to indicate that the function will modify self?
    modifier
    mutating
    mutable
    mod
    mut

  10. Which of the following statements about Extensions is false?
    Extensions can add new functionality to a type.
    Keyword for Extensions is \"extension\".
    Extension can override existing functionality.
    Extensions can make an existing type confirm to a protocol.

Note: Answers are not given intentionally.