Bird
0
0

What will happen if a class declares conformance to a protocol but does not implement all required methods?

medium📝 Predict Output Q5 of 15
iOS Swift - Swift Language Essentials
What will happen if a class declares conformance to a protocol but does not implement all required methods?
AThe code compiles but crashes at runtime
BThe missing methods are automatically implemented
CThe compiler shows an error
DThe class ignores the protocol requirements
Step-by-Step Solution
Solution:
  1. Step 1: Recall Swift compiler behavior

    Swift requires all protocol requirements to be implemented by conforming types at compile time.
  2. Step 2: Consequence of missing implementations

    If any required method is missing, the compiler will produce an error and prevent compilation.
  3. Final Answer:

    The compiler shows an error -> Option C
  4. Quick Check:

    Protocol conformance missing methods = compile error [OK]
Quick Trick: All protocol methods must be implemented to compile [OK]
Common Mistakes:
  • Expecting runtime crash
  • Thinking methods auto-implemented
  • Ignoring protocol requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes