Bird
0
0

Which of the following is the correct way to call the function declared as func greet(person name: String)?

easy📝 Syntax Q3 of 15
Swift - Functions
Which of the following is the correct way to call the function declared as func greet(person name: String)?
Agreet(person: "Anna")
Bgreet(name: "Anna")
Cgreet("Anna")
Dgreet(person name: "Anna")
Step-by-Step Solution
Solution:
  1. Step 1: Identify the argument label in the function declaration

    The function uses person as the argument label and name as the parameter name.
  2. Step 2: Use the argument label when calling the function

    Calls must use the argument label person, so the correct call is greet(person: "Anna").
  3. Final Answer:

    greet(person: "Anna") -> Option A
  4. Quick Check:

    Use argument label in call = greet(person: "Anna") [OK]
Quick Trick: Call functions using argument labels, not parameter names [OK]
Common Mistakes:
  • Using parameter name instead of argument label in call
  • Omitting argument label when required
  • Using both argument label and parameter name in call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes