Certs Vault
See all results for ""
Home Exams
CRISC ISACA CISSP ISC2 200-301 Cisco SY0-701 CompTIA AZ-104 Microsoft AI-900 Microsoft AIGP IAPP 1Z0-1067-26 Oracle View All Exams →
Sign in Create account

App Development with Swift Certified User Exam App-Development-with-Swift-Certified-User Exam Questions

Preparing for the App-Development-with-Swift-Certified-User exam is simple with Certs Vault. We offer easy-to-understand study materials that help you learn the most important exam topics. You can study using our PDF questions, practice online with a real exam-style test, or use the desktop practice software. Choose the study method that works best for you and prepare at your own pace.

At Certs Vault, we keep our App-Development-with-Swift-Certified-User practice questions up to date. Whenever the exam syllabus or objectives change, we update our study materials so you always learn the latest topics. This helps you save time, avoid outdated content, and feel more confident when you take your exam.

Download Exam View Entire Exam
Page: 1 / 1
Question #1 (Topic: Demo Questions)

Review the code.
var capitalCities = [ " USA " : " Washington D.C. " , " Spain " : " Madrid " , " Peru " : " Lima " ]
Which two statements add the capital city of " Italy " to the dictionary? (Choose 2.)

A.
capitalCities[ " Rome " ] = " Italy "
B.
capitalCities.append([ " Italy " : " Rome " ])
C.
capitalCities[ " Italy " ] = " Rome "
D.
capitalCities = capitalCities + [ " Italy " : " Rome " ]
E.
capitalCities.updateValue( " Rome " , forKey: " Italy " )
Correct Answer: C, E
Explanation:
Comprehensive and Detailed Explanation From App Development with Swift domains:
This question falls under Swift Programming Language , specifically the domain for managing data using collection types , with emphasis on dictionaries . In Swift, a dictionary stores data as key value pairs , so in this example the country name is the key and the capital city is the value. To add a new entry, Swift supports two standard approaches. The first is subscript assignment , which is shown in option C : capitalCities[ " Italy " ] = " Rome " . Apple’s documentation explains that you can add a key-value pair to a dictionary by assigning a value for a new key through the dictionary subscript.
The second correct approach is option E : capitalCities.updateValue( " Rome " , forKey: " Italy " ). Apple documents that updateValue(_:forKey:) updates the value for an existing key, or adds a new key-value pair if the key does not already exist . That makes it equally valid for inserting " Italy " : " Rome " into the dictionary.
The incorrect options fail for different reasons. A reverses the key and value, making " Rome " the key and " Italy " the value. B is wrong because append is used with arrays, not dictionaries. D is not the standard valid insertion syntax for Swift dictionaries in this context; Swift’s documented mutation approaches here are subscript assignment and updateValue. Therefore, the two correct answers are C and E .
Download Exam
Page: 1 / 1
Next Page