Apple App Development with Swift Certified User - App-Development-with-Swift-Certified-User Exam Practice Test

Question 1
If View A calls View B, which Swift Property Wrapper would you use in View B in order to return the value of a state to View A?

Correct Answer: B
Explanation: Only visible for Actualtests4sure members. You can sign-up / login (it's free).
Question 2
You are creating or updating human resource records for your employees. For each identifier, select whether it is a Constant or a Variable Note: You will receive partial credit for each correct answer.
Correct Answer:

Explanation:
* age - Variable
* birthDate - Constant
* socialSecurityNumber - Constant
* salary - Variable
* currentDepartment - Variable
This question belongs to Swift Programming Language , specifically the objective on demonstrating when to use constants and variables . In Swift, a constant is declared with let and is used for values that should not change after they are set. A variable is declared with var and is used for values that may change over time.
Birth date is a constant because a person's date of birth does not change. Social security number is also a constant because it is intended to be a fixed identifier for that employee record. By contrast, age is a variable because it changes over time. Salary is a variable because compensation can be adjusted. Current department is also a variable because an employee may transfer to another department.
This matches Swift best practice: use let for fixed data and var for mutable data. So in a human resources record, identifiers that are permanent should be constants, while values that can change during employment should be variables.
Question 3
In SwiftUI, how can you extract a subview from a main view to make the code more modular?

Correct Answer: B
Explanation: Only visible for Actualtests4sure members. You can sign-up / login (it's free).
Question 4
Complete the code by selecting the correct option from each drop-down list to create the following screen.

Note: You will receive partial credit for each correct answer.
Correct Answer:

Question 5
Review the code snippet.

What value does the code output?
Correct Answer:
Answer the question by typing in the box.
2
Explanation:
This question belongs to Swift Programming Language , specifically the objectives covering functions , control flow , and default parameter values . The function is declared as func getAgeCategory(_ age: Int =
20) - > Int, which means if no argument is supplied, Swift uses the default value 20. Apple's Swift documentation explains that you can define a default value for any parameter, and that value is used when the caller omits that argument. Since the code calls getAgeCategory() with no parameter, the function executes using age = 20.
The conditional logic is then evaluated in order:
* if age > 64 # false, because 20 is not greater than 64
* else if age > 19 # true, because 20 is greater than 19
* so the function returns 2
Because Swift's if / else if control flow stops at the first true condition, the later checks are never reached once age > 19 succeeds. Apple describes Swift as supporting standard control flow including conditional branching, and this example is a direct use of that branching behavior.
Therefore, print(getAgeCategory()) outputs 2 , which corresponds to option B .