Questions
- Which of the following is relevant in Protocol-Oriented Programming?
a) The type an object has. b) The object's superclass. c) What an object can do.
- Which of the following is not a downside of subclassing?
a) Shared functionality. b) A fixed subclassing hierarchy. c) A complex inheritance graph.
- Protocols can inherit from several other protocols. True or false?
a) True. b) False.
- An associated type has to be a struct or class. True or false?
a) True. b) False.
- In which two ways can a struct specify what type an associated type for a protocol is?
a) By using a typealias. b) By using generics on the struct. c) By conforming to a protocol.
- What does T mean in
genericFunction<T>()
?
a) It refers to a type called T. b) It refers to a type that conforms to a T protocol. c) T is a placeholder for the generic type.