Docsity

Certified iPhone Apps Developer Practice Exam, Exams of Technology

Toggle sidebar
bg1
Certified iPhone Apps Developer Practice
Exam
**Question 1. Which keyword is used in Swift to indicate that a variable’s value cannot be
changed after it is set?**
A) var
B) let
C) const
D) static
Answer: B
Explanation: In Swift, `let` declares a constant whose value is immutable after initialization,
whereas `var` declares a mutable variable.
**Question 2. What is the result of type inference for the following declaration? `let number =
42`**
A) Int
B) Double
C) Float
D) UInt
Answer: A
Explanation: Swift infers `number` as an `Int` because the literal `42` is an integer without a
decimal point.
**Question 3. Which collection type guarantees unique elements and provides fast membership
testing?**
A) Array
B) Dictionary
C) Set
D) Tuple
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c

Partial preview of the text

Download Certified iPhone Apps Developer Practice Exam and more Exams Technology in PDF only on Docsity!

Exam

Question 1. Which keyword is used in Swift to indicate that a variable’s value cannot be changed after it is set? A) var B) let C) const D) static Answer: B Explanation: In Swift, let declares a constant whose value is immutable after initialization, whereas var declares a mutable variable. Question 2. What is the result of type inference for the following declaration? let number = 42 A) Int B) Double C) Float D) UInt Answer: A Explanation: Swift infers number as an Int because the literal 42 is an integer without a decimal point. Question 3. Which collection type guarantees unique elements and provides fast membership testing? A) Array B) Dictionary C) Set D) Tuple

Exam

Answer: C Explanation: A Set stores unique values and offers O(1) average-time complexity for membership checks. Question 4. How do you safely unwrap an optional value without using force‑unwrap (!)? A) Using if let B) Using guard let C) Using optional chaining D) All of the above Answer: D Explanation: All three techniques (if let, guard let, optional chaining) provide safe ways to handle optionals without risking a runtime crash. Question 5. Which Swift construct allows you to associate multiple values of different types together without naming them? A) Struct B) Class C) Tuple D) Enum Answer: C Explanation: Tuples group multiple values into a single compound value and can contain elements of different types. Question 6. In a for‑in loop, which of the following statements correctly iterates over the keys of a dictionary named scores? A) for key in scores {}

Exam

Question 9. Which of the following correctly declares a structure with a stored property name of type String and a computed property greeting? A) struct Person { var name: String; var greeting: String { return "Hi, \\(name)" } } B) struct Person { let name: String; var greeting: String { "Hi, \\(name)" } } C) struct Person { var name: String; var greeting: String = "Hi" } D) struct Person { var name: String; func greeting() - > String { "Hi, \\(name)" } } Answer: A Explanation: Option A defines a stored property name and a computed property greeting that returns a string based on name. Question 10. In Swift, which access control level allows a class member to be accessed from any source file within the same module and also from subclasses in other modules? A) private B) fileprivate C) internal D) open Answer: D Explanation: open is the least restrictive access level, permitting subclassing and overriding outside the defining module. Question 11. What is the purpose of a deinitializer (deinit) in a Swift class? A) To initialize properties before use B) To release resources when an instance is about to be deallocated C) To create a copy of the object D) To enforce immutability

Exam

Answer: B Explanation: deinit is called automatically just before an instance’s memory is reclaimed, allowing cleanup of resources. Question 12. Which of the following statements about ARC (Automatic Reference Counting) is true? A) ARC works only with structs. B) ARC automatically frees memory for objects with zero strong references. C) ARC requires manual retain and release calls. D) ARC can detect retain cycles without developer intervention. Answer: B Explanation: ARC tracks strong references; when an object’s strong reference count drops to zero, it is deallocated automatically. Question 13. To prevent a retain cycle between two class instances, which reference type should be used for the back‑reference? A) strong B) weak C) unowned D) lazy Answer: B Explanation: Declaring the back‑reference as weak breaks the strong reference cycle, allowing ARC to deallocate the objects. Question 14. Which protocol method is required for a class to conform to the Equatable protocol? A) func hash(into:)

Exam

Question 17. In the delegation pattern, which keyword is typically used to declare the delegate property to avoid strong reference cycles? A) strong B) weak C) unowned D) static Answer: B Explanation: Delegates are usually declared weak because the delegating object often holds a strong reference to its delegate, and a weak reference prevents a retain cycle. Question 18. Which Xcode pane displays breakpoints, the call stack, and variable values while debugging? A) Project Navigator B) Debug area C) Interface Builder D) Report navigator Answer: B Explanation: The Debug area contains the console, variables view, and the call stack during a debugging session. Question 19. To create a new target configuration in Xcode, you would modify which of the following? A) Info.plist B) Build Settings C) Schemes D) Asset Catalog

Exam

Answer: C Explanation: Schemes define which target and configuration (Debug, Release, etc.) are built and run. Question 20. Which instrument is most appropriate for identifying memory leaks in an iOS app? A) Time Profiler B) Allocations C) Leaks D) Energy Log Answer: C Explanation: The Leaks instrument specifically tracks objects that have been allocated but not deallocated, indicating memory leaks. Question 21. In the iOS application lifecycle, which state occurs immediately after the user presses the Home button while the app is active? A) Not Running B) Background C) Suspended D) Inactive Answer: D Explanation: Pressing Home moves the app from Active to Inactive, then shortly to Background and eventually Suspended. Question 22. Which AppDelegate method is called when the app finishes launching? A) applicationDidBecomeActive(_:)

Exam

Question 25. In SwiftUI, which property wrapper should be used for an object that is created and owned by the view itself? A) @State B) @Binding C) @ObservedObject D) @StateObject Answer: D Explanation: @StateObject creates and retains an observable object for the life of the view, ensuring it is not recreated on view updates. Question 26. Which SwiftUI view modifier adds padding of 16 points on all sides? A) .padding(16) B) .frame(padding: 16) C) .spacing(16) D) .margin(16) Answer: A Explanation: The .padding(_:) modifier inserts the specified amount of space around the view. Question 27. How do you create a vertical stack of views in SwiftUI? A) HStack B) VStack C) ZStack D) StackView Answer: B

Exam

Explanation: VStack arranges its child views vertically. Question 28. Which SwiftUI view enables navigation between a list of items and a detail view using a navigation bar? A) TabView B) NavigationStack C) List D) Form Answer: B Explanation: NavigationStack (or the older NavigationView) provides a navigation hierarchy with a navigation bar. Question 29. To reuse a piece of UI across multiple SwiftUI views, you should create: A) A UIViewController subclass B) A struct conforming to View C) A class inheriting from NSObject D) A protocol with default implementation Answer: B Explanation: SwiftUI views are structs conforming to the View protocol; they can be reused wherever needed. Question 30. Which UIKit lifecycle method is called only once when the view controller’s view is first loaded into memory? A) viewWillAppear(_:) B) viewDidLoad() C) viewDidLayoutSubviews()

Exam

A) UIViewRepresentable B) UIViewControllerRepresentable C) SwiftUIRepresentable D) Both A and B, depending on the UIKit component Answer: D Explanation: UIViewRepresentable is used for UIView subclasses, while UIViewControllerRepresentable wraps view controllers. Question 34. Which gesture recognizer should be used to detect a long‑press action? A) UITapGestureRecognizer B) UISwipeGestureRecognizer C) UILongPressGestureRecognizer D) UIPanGestureRecognizer Answer: C Explanation: UILongPressGestureRecognizer fires after the user presses and holds for a configurable duration. Question 35. When implementing accessibility for a custom button, which UIAccessibility property provides a spoken description? A) accessibilityLabel B) accessibilityHint C) accessibilityValue D) accessibilityTraits Answer: A Explanation: accessibilityLabel is read aloud by VoiceOver to describe the element.

Exam

Question 36. Which iOS API is used to store small pieces of user data like a Boolean flag indicating first‑launch? A) Core Data B) Keychain C) UserDefaults D) FileManager Answer: C Explanation: UserDefaults is ideal for lightweight, non‑secure data such as user preferences. Question 37. To encode a Swift struct to JSON, which protocol must the struct conform to? A) NSCoding B) Codable C) Serializable D) JSONRepresentable Answer: B Explanation: Conforming to Codable (which combines Encodable and Decodable) enables automatic JSON encoding/decoding. Question 38. Which Core Data class is responsible for managing the object graph and persisting changes to the SQLite store? A) NSManagedObject B) NSManagedObjectContext C) NSPersistentStoreCoordinator D) NSFetchRequest Answer: B

Exam

C) MKPointAnnotation D) MKPlacemark Answer: C Explanation: MKPointAnnotation represents a simple point on the map that can be displayed as a pin. Question 42. Which iOS framework provides secure storage for passwords and cryptographic keys? A) UserDefaults B) Core Data C) Keychain Services D) FileManager Answer: C Explanation: The Keychain is encrypted and managed by the OS, making it suitable for sensitive data. Question 43. To authenticate a user with Touch ID or Face ID, which class should be used? A LAContext B) AuthProvider C) BiometricAuthenticator D) SecureEnclave Answer: A Explanation: LAContext from the LocalAuthentication framework handles biometric and passcode authentication.

Exam

Question 44. Which method of UNUserNotificationCenterDelegate is called when a notification is delivered while the app is in the foreground? A) userNotificationCenter(_:didReceive:withCompletionHandler:) B) userNotificationCenter(_:willPresent:withCompletionHandler:) C) userNotificationCenter(_:openSettingsFor:) D) userNotificationCenter(_:didRegister:) Answer: B Explanation: willPresent allows the app to decide how to present a notification when it is active. Question 45. In a RESTful API, which HTTP method is conventionally used to update a resource partially? A) GET B) POST C) PUT D) PATCH Answer: D Explanation: PATCH applies partial modifications to a resource, whereas PUT replaces the entire resource. Question 46. Which URLSession task type is appropriate for downloading a large file to a temporary location? A) dataTask B) uploadTask C) downloadTask D) streamTask

Exam

B) .error C) .success D) .ok Answer: C Explanation: Result<Success, Failure> has two cases: .success(Success) and .failure(Failure). Question 50. Which instrument helps identify CPU hotspots by showing the call stack frequency? A) Leaks B) Time Profiler C) Allocations D) Energy Log Answer: B Explanation: The Time Profiler records how much CPU time each stack trace consumes, highlighting performance bottlenecks. Question 51. Which XCTest assertion checks that two values are equal? A) XCTAssertTrue B) XCTAssertEqual C) XCTAssertNil D) XCTAssertThrowsError Answer: B Explanation: XCTAssertEqual verifies that two expressions produce equal values. Question 52. In unit testing, what does the “Arrange” step refer to?

Exam

A) Executing the code under test B) Setting up test data and environment C) Verifying the results D) Cleaning up after the test Answer: B Explanation: “Arrange” prepares inputs, mocks, and any required state before the action is performed. Question 53. Which XCUITest method launches the app before performing UI actions? A) XCUIApplication().activate() B) XCUIApplication().launch() C) XCUIElement().tap() D) XCUIElementQuery().firstMatch Answer: B Explanation: XCUIApplication().launch() starts the target app for UI testing. Question 54. To uniquely identify a UI element for UI tests, which property should you set? A) tag B) accessibilityIdentifier C) restorationIdentifier D) accessibilityLabel Answer: B Explanation: accessibilityIdentifier is not read by VoiceOver but is used by UI tests to locate elements reliably.