iOS

Protocol Oriented Programming

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

20 Interview-Fragen·
Mid-Level
1

What is a protocol in Swift?

Antwort

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?

Antwort

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?

Antwort

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 Interview-Fragen

Meistere iOS für dein nächstes Interview

Zugang zu allen Fragen, Flashcards, technischen Tests, Code-Review-Übungen und Interview-Simulatoren.

Kostenlos starten