• 20 hours
  • Medium

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 5/25/20

Enrich the code implementation

Log in or subscribe for free to enjoy all this course has to offer!

Evaluated skills

  • Understand advanced techniques of class implementation
  • Question 1

    What will be printed in the console after execution of the following code sample:

    class Rect {
    var width = 2
    var length = 4
    var perimeter: Int {
    get {
    return (width + length) * 2
    }
    }
    }
    var rect = Rect()
    rect.width = 3
    rect.length = 5
    print(rect.perimeter)

     

    • 8

    • 12

    • 15

    • 16

  • Question 2

    Which properties of the Fruit class cannot be changed?

    class Dinner {
    let cuisine = "Italian"
    var calories = 800
    var mealCost = 0.0
    var deliveryCost = 0.0
    var totalPrice: Double {
    return mealCost + deliveryCost
    }
    }

     

    Careful, there are several correct answers.
    • cuisine

       

    •  

      calories

    • mealCost

    • deliveryCost

    • totalPrice

    • All properties CAN be modified

    • All properties CAN NOT be modified

  • Question 3

    Select the property observers for stored properties:

    Careful, there are several correct answers.
    • get

    • set 

    • willSet

       

    • didSet

    • Stored properties cannot be observed.