Bird
0
0

Which of the following types can be marked with @main to define the program's entry point?

easy📝 Conceptual Q2 of 15
Swift - Basics and Runtime
Which of the following types can be marked with @main to define the program's entry point?
AOnly classes
BOnly enums
COnly structs
DStructs, classes, or enums
Step-by-Step Solution
Solution:
  1. Step 1: Recall @main usage

    The @main attribute can be applied to structs, classes, or enums.
  2. Step 2: Confirm allowed types

    All three types can provide a static main() method to serve as the entry point.
  3. Final Answer:

    Structs, classes, or enums -> Option D
  4. Quick Check:

    @main allowed types = struct, class, enum [OK]
Quick Trick: @main works on struct, class, or enum types [OK]
Common Mistakes:
  • Thinking only classes can use @main
  • Believing enums cannot be entry points
  • Assuming @main applies to functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes