iOS

Protocol Oriented Programming

Protocols, extensions, default implementations, PATs, protocol composition, type erasure

20 gespreksvragenยท
Mid-Level
1

What is a protocol in Swift?

Antwoord

A protocol defines a set of properties and methods that a type must implement. It acts as a contract between the protocol and conforming types. Protocols enable interface definition without imposing inheritance hierarchies, promoting composition and code reusability.

2

What is protocol conformance?

Antwoord

Conformance means a type (class, struct, or enum) implements all required properties and methods from a protocol. A type can conform to multiple protocols simultaneously. Conformance establishes a type relationship independent of inheritance.

3

What is a protocol extension?

Antwoord

A protocol extension provides default implementations for protocol methods. All conforming types receive these implementations automatically without redefining them. This promotes code reuse and significantly reduces boilerplate.

4

How to define a protocol with a required property?

5

What is protocol inheritance?

+17 gespreksvragen

Beheers iOS voor je volgende gesprek

Krijg toegang tot alle vragen, flashcards, technische tests, code review-oefeningen en gespreksimulatoren.

Begin gratis