Unit 2: MVVM Architecture - Practice Quiz

INT372 — Iphone Application Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does MVVM stand for?

Introduction to MVVM architecture Easy
A. Model-View-ViewController
B. Model-View-ViewModel
C. Model-Visual-ViewManager
D. Module-View-VisualModel

2 Which MVVM component stores and manages application data?

Introduction to MVVM architecture Easy
A. Model
B. ViewModel
C. View
D. Controller

3 What is the main role of the ViewModel in MVVM?

Introduction to MVVM architecture Easy
A. To create application certificates
B. To install the iOS Simulator
C. To connect data with the View
D. To display the Xcode toolbar

4 What is Xcode mainly used for?

Introduction to Xcode Easy
A. Creating database server clusters
B. Developing Apple platform applications
C. Managing Android application packages
D. Designing computer network cables

5 Which part of the Xcode workspace is primarily used to edit source code?

Workspace window Easy
A. Utility area
B. Editor area
C. Debug area
D. Navigator area

6 What is Interface Builder used for in Xcode?

Interface Builder Easy
A. Installing operating system updates
B. Creating source control accounts
C. Designing user interfaces visually
D. Managing remote database servers

7 What can be changed using the Attribute inspector?

Attribute inspector Easy
A. The simulator's operating system
B. The application's signing certificate
C. The computer's network connection
D. Properties of a selected UI element

8 What is the main purpose of the iOS Simulator?

Simulator and creating project Easy
A. To design icons for an iOS app
B. To publish an app to the App Store
C. To convert Swift code into Java code
D. To test an app on a simulated device

9 Which Xcode command is commonly used to begin creating a new application project?

Simulator and creating project Easy
A. Create a new Xcode project
B. Install additional components
C. Connect to a remote repository
D. Open Developer Documentation

10 What is a view controller mainly responsible for?

Looking at view controller Easy
A. Managing a screen and its views
B. Installing third-party frameworks
C. Publishing apps to the store
D. Managing the Mac file system

11 What is an IBOutlet used for?

Understanding outlets Easy
A. Connecting a UI element to code
B. Opening the device camera directly
C. Creating a new Swift package
D. Starting an application download

12 Which keyword commonly appears before an outlet declaration in UIKit?

Understanding outlets Easy
A. @IBOutlet
B. @UIApplicationMain
C. @available
D. @IBAction

13 What does an IBAction usually represent?

Actions Easy
A. A method triggered by a UI event
B. A variable storing a UI element
C. A file containing application data
D. A tool for selecting simulators

14 Which user interaction can commonly trigger an action connected to a UIButton?

Actions Easy
A. Tapping the button
B. Building the workspace
C. Opening the navigator
D. Renaming the project

15 Which UI element is normally used to display a short piece of text?

Designing UI Easy
A. UILabel
B. UISwitch
C. UISlider
D. UIButton

16 What is Auto Layout used for in an iOS interface?

Designing UI Easy
A. Downloading content from a server
B. Compiling Swift source code
C. Positioning UI elements with constraints
D. Saving application data to files

17 What is a common responsibility of the application delegate?

Application delegate Easy
A. Storing every user preference
B. Writing all ViewModel properties
C. Drawing every interface element
D. Responding to application-level events

18 Which navigator is used to browse project files in Xcode?

Working with navigator pane Easy
A. Report navigator
B. Test navigator
C. Issue navigator
D. Project navigator

19 What does the Utility pane commonly contain?

Utility pane Easy
A. Only the application's source files
B. Simulator hardware controls
C. Inspectors and interface libraries
D. Only compiler error messages

20 In which application state is an iOS app visible and receiving user input?

Activity life cycle Easy
A. Active
B. Background
C. Suspended
D. Inactive

21 A view controller currently downloads user data, formats it, and updates labels. Under MVVM, where should the formatting logic primarily be moved?

Introduction to MVVM architecture Medium
A. The storyboard scene that contains the labels and layout constraints
B. The AppDelegate
C. The ViewModel
D. The Model

22 A ViewModel exposes an isLoginEnabled property based on whether two text fields contain valid values. What is the main architectural benefit?

Introduction to MVVM architecture Medium
A. The Model can directly modify the button
B. The application delegate owns all login state and updates every controller
C. The storyboard automatically validates both fields
D. Validation can be tested without creating the view

23 An iOS project compiles successfully but crashes while running. Which Xcode feature is most appropriate for pausing execution at the suspected line and inspecting variables?

Introduction to Xcode Medium
A. A scheme archive action
B. A project navigator group containing the affected source files
C. A constraint in Interface Builder
D. A breakpoint in the source editor

24 While debugging a layout issue, a developer wants more horizontal space for the source editor without closing the project. Which workspace adjustment is most suitable?

Workspace window Medium
A. Hide the navigator and inspector areas
B. Delete unused project file groups
C. Open the storyboard through the application delegate and rebuild the scheme
D. Change the active build configuration

25 A label is correctly positioned on one iPhone size but shifts incorrectly on another. What should the developer modify in Interface Builder?

Interface Builder Medium
A. The Auto Layout constraints
B. The application bundle identifier
C. The ViewModel access level
D. The complete simulator runtime configuration for every supported device

26 A developer needs to change a button's displayed title and text color without writing code. Which Xcode area should be used?

Attribute inspector Medium
A. The Report navigator
B. The File inspector, after changing the target membership and localization settings
C. The Debug navigator
D. The Attribute inspector

27 A newly created application must be checked on two simulated iPhone screen sizes. What is the most efficient approach?

Simulator and creating project Medium
A. Change the bundle identifier before each run
B. Run the same scheme on two simulator devices
C. Duplicate every view controller and configure one copy for each simulated screen size
D. Create a separate Xcode project for each device

28 An application needs camera behavior that the selected Simulator runtime cannot reproduce accurately. What should the developer do?

Simulator and creating project Medium
A. Create another simulator-only target with a different bundle identifier and signing certificate
B. Add a camera constraint in the storyboard
C. Test that behavior on a physical device
D. Move camera code into the application delegate

29 A view controller must configure a label after all storyboard outlets have been connected. Which method is the appropriate place for this initial setup?

Looking at view controller Medium
A. viewDidLoad()
B. application(_:didFinishLaunchingWithOptions:) in the application delegate
C. loadView()
D. viewWillDisappear(_:)

30 A screen refreshes account data every time it becomes visible after another screen is dismissed. Which view controller method best fits this requirement?

Looking at view controller Medium
A. viewWillAppear(_:)
B. viewWillDisappear(_:)
C. viewDidLoad()
D. didReceiveMemoryWarning(), because it is called before a previously hidden screen is displayed again

31 An IBOutlet is declared as weak, but the connected label remains visible and usable after loading. What retains the label?

Understanding outlets Medium
A. Its superview
B. The outlet declaration
C. The ViewModel
D. The application delegate through the active storyboard and navigation stack

32 A storyboard label was connected to titleLabel, but the property was later deleted from the view controller. What is the likely runtime result if the stale connection remains?

Understanding outlets Medium
A. A silent replacement outlet is generated
B. The storyboard reconnects the label to the nearest property with a compatible UIKit type
C. A key-value coding connection exception
D. A compile-time Auto Layout warning

33 Several buttons should call the same IBAction, while the method must identify which button triggered it. Which method signature is most useful?

Actions Medium
A. @IBAction func choose()
B. func choose(_ sender: UIViewController)
C. @IBAction func choose(_ sender: UIButton)
D. @IBOutlet weak var choose: UIButton!, followed by a separate action stored in the application delegate

34 A button's action is connected to the Touch Down event instead of Touch Up Inside. What behavioral difference should be expected?

Actions Medium
A. The action fires when the view controller loads
B. The action fires only after the finger leaves
C. The action waits until the application enters the background and the current scene resigns active
D. The action fires when the finger first presses

35 Three buttons should remain equal in width and evenly spaced as the device rotates. Which Interface Builder approach is most appropriate?

Designing UI Medium
A. Update their frames only in viewDidLoad()
B. Place them in a horizontal stack view
C. Assign each button a fixed screen coordinate
D. Create three separate view controllers and embed one button in each controller's root view

36 Which task is most appropriately performed in application(_:didFinishLaunchingWithOptions:)?

Application delegate Medium
A. Initialize an application-wide service
B. Apply individual Auto Layout constraints to each storyboard scene after every device rotation
C. Update a label whenever its screen appears
D. Handle every button tap in the application

37 A build fails because a symbol is undefined, and the developer wants to jump directly through the listed compiler errors. Which navigator should be opened?

Working with navigator pane Medium
A. The Breakpoint navigator
B. The Issue navigator
C. The Symbol navigator
D. The Project navigator with every group expanded and all generated build products displayed

38 A source file compiles in the project but is missing from one application target. Which inspector setting should be checked in the utility pane?

Utility pane Medium
A. Module Stability
B. The complete list of simulator devices installed for all Xcode toolchains
C. Content Mode
D. Target Membership

39 An application pauses an active timer when it is interrupted by an incoming call. In a traditional app-delegate lifecycle, which callback is most appropriate?

Activity life cycle Medium
A. applicationWillEnterForeground(_:)
B. application(_:didFinishLaunchingWithOptions:), because interruptions restart the application lifecycle
C. applicationWillResignActive(_:)
D. applicationDidBecomeActive(_:)

40 A scene-based application should refresh sensitive information whenever its scene returns from the background and becomes interactive. Which callback best matches that moment?

Activity life cycle Medium
A. sceneWillResignActive(_:)
B. sceneDidBecomeActive(_:)
C. sceneDidEnterBackground(_:)
D. applicationWillTerminate(_:), followed by reloading the storyboard and reconstructing every visible controller

41 A view controller owns a view model, and the view model exposes a closure that the controller assigns to update its UI. Instruments shows that the controller is never deallocated after dismissal. Which change best preserves MVVM communication while fixing the likely leak?

Introduction to MVVM architecture Hard
A. Declare every view-model property weak and recreate the model after each update
B. Move the closure into the model and retain the controller through a protocol property
C. Capture the controller weakly in the closure and unwrap it before updating the UI
D. Make the controller a singleton so the retained instance is reused across presentations

42 A view model fetches data on a background queue and publishes a formatted string that is immediately assigned to a label by the view controller. Which design most correctly handles thread safety and MVVM separation?

Introduction to MVVM architecture Hard
A. Format in the view controller and update the label directly from the background queue
B. Format in the view model and deliver the observable UI state on the main thread
C. Store the label in the view model and dispatch its property changes to the main thread
D. Return the network response unchanged and let the label parse it on the main thread

43 An Xcode workspace contains an application project and a separate dynamic framework project. Both build independently, but the application reports that the framework module cannot be loaded at runtime. Which configuration is most appropriate?

Introduction to Xcode Hard
A. Add the framework's source directory only to the app's header search paths
B. Select the framework scheme whenever the application is launched from Xcode
C. Copy the framework project file into the application's compiled resources phase
D. Add the framework product to the app's frameworks section using Embed & Sign

44 Which mapping of Xcode workspace-window components to responsibilities is correct?

Workspace window Hard
A. Scheme selector—source control branch; jump bar—build settings; debug area—target membership
B. Scheme selector—run destination; jump bar—code navigation; debug area—variables and console
C. Scheme selector—breakpoint scope; jump bar—simulator selection; debug area—asset management
D. Scheme selector—file history; jump bar—target signing; debug area—storyboard constraints

45 A view with width points contains a subview with required leading and trailing constraints of points and a required width constraint of points. The design must preserve both margins on different screen widths. Which Interface Builder change is most appropriate?

Interface Builder Hard
A. Add a required center constraint while retaining all three existing required constraints
B. Lower the leading constraint priority so the fixed width determines the horizontal position
C. Raise content-hugging priority so the intrinsic size overrides both required margins
D. Lower the width constraint priority below required so the margins determine the width

46 A developer must set a button's title for its Disabled state, assign an accessibility identifier, and change the storyboard file's target membership. Which inspector sequence should be used?

Attribute inspector Hard
A. Size inspector, Connections inspector, File inspector
B. Attributes inspector, Size inspector, Quick Help inspector
C. Identity inspector, Attributes inspector, Connections inspector
D. Attributes inspector, Identity inspector, File inspector

47 An image named ProfileIcon.png loads in the Simulator, but returns nil on a physical device when requested as profileicon.png. Assuming the asset is copied correctly, what is the most likely cause?

Simulator and creating project Hard
A. The simulator loads missing images from Xcode's global derived-data image cache
B. The simulator's host file system tolerates a filename case mismatch that the device does not
C. The device automatically converts PNG filenames into lowercase names during installation
D. The physical device requires all PNG resources to be registered as launch-screen assets

48 In a scene-based iOS project, a developer removes the main storyboard reference from the target settings and creates the window programmatically, but launch still fails while trying to load that storyboard. What was most likely overlooked?

Simulator and creating project Hard
A. The storyboard is still selected as the active file in the project navigator
B. The simulator cached the storyboard because derived data contains compiled Swift modules
C. The storyboard name remains in the scene configuration within the application manifest
D. The root view controller must be created exclusively in the application delegate initializer

49 A parent view controller programmatically embeds a child controller. Which sequence correctly establishes containment before the child begins normal appearance handling?

Looking at view controller Hard
A. Add and constrain its view, call viewDidAppear, then call addChild
B. Call didMove(toParent:), add its view, then call addChild
C. Call addChild, add and constrain its view, then call didMove(toParent:)
D. Present the child modally, add its view, then dismiss the presentation

50 A XIB contains a helper object as a top-level object. It is connected to a weak outlet but is not inserted into any retained view hierarchy. The outlet becomes nil after loading. What is the best correction?

Understanding outlets Hard
A. Make the outlet strong so the owner retains the top-level helper object
B. Keep the outlet weak and add the helper object to the controller's view hierarchy
C. Declare the outlet computed so the XIB reconstructs the object on every access
D. Convert the outlet into an action so Interface Builder retains its target

51 A view model receives data before its view controller's view has loaded. A property observer immediately assigns the data to an implicitly unwrapped label outlet, causing a crash. Which solution best handles this edge case?

Understanding outlets Hard
A. Force access to every outlet in the controller initializer before assigning the view model
B. Move the label into the view model so it exists before storyboard unarchiving begins
C. Store the state and render it in viewDidLoad, updating immediately only when isViewLoaded is true
D. Convert the label outlet to a class property shared by every controller instance

52 Four buttons are connected to one IBAction, and their visible titles are localized. The controller must reliably determine which command was requested. Which approach is most robust?

Actions Hard
A. Inspect the current touch coordinates and infer which localized command was tapped
B. Use the sender's position because Auto Layout preserves a fixed visual order
C. Compare the sender with known outlets or map each control to a command identifier
D. Compare the sender's displayed title with hard-coded English command strings

53 A reusable table-view cell calls addTarget(_:action:for:) on its button every time configure runs. After several reuse cycles, one tap invokes the same action multiple times. What is the safest design correction?

Actions Hard
A. Remove every target in prepareForReuse, including targets installed by other components
B. Create a new button in every configuration call and leave the old button attached
C. Register the invariant target-action once during cell initialization rather than during configuration
D. Disable user interaction during reuse and re-enable it after each configuration call

54 A multiline label supports Dynamic Type but clips text at accessibility sizes. It has required top and bottom constraints, numberOfLines = 0, and a required fixed-height constraint. Which redesign best preserves accessibility?

Designing UI Hard
A. Remove the bottom constraint and position the label using an absolute frame origin
B. Keep the fixed height and reduce the font whenever the preferred size category increases
C. Change the label to one line and enable truncation at the tail for all size categories
D. Remove the fixed height and let intrinsic content size determine the label's vertical size

55 An interface must switch from a vertical control arrangement in compact width to a horizontal arrangement in regular width, including Split View resizing on iPad. Which design is most reliable?

Designing UI Hard
A. Use trait-aware constraints or stack-view axis changes based on the current size class
B. Create separate controllers and choose one exclusively from the operating-system version
C. Select the arrangement only from the launch screen's initial pixel dimensions
D. Select the arrangement once by comparing the device model with a stored phone list

56 A background URLSession finishes transfers while the application is suspended. iOS relaunches the app and provides a completion handler to the application delegate. When should that handler be called?

Application delegate Hard
A. When the first download task reports progress greater than zero after relaunch
B. After the session delegate reports that all background events have finished processing
C. Only when the application next becomes active and displays its root controller
D. Immediately inside didFinishLaunchingWithOptions before restoring session delegates

57 A test passed locally yesterday but failed in an earlier CI-style Xcode run. The developer needs the complete logs and results from that historical test invocation. Which navigator is most appropriate?

Working with navigator pane Hard
A. Breakpoint navigator
B. Report navigator
C. Issue navigator
D. Symbol navigator

58 A developer selects a storyboard constraint and wants to edit its constant and priority, then selects a Swift file and wants to change its target membership. Which utility-pane inspectors are required in order?

Utility pane Hard
A. Size inspector, then File inspector
B. Connections inspector, then Quick Help inspector
C. File inspector, then Attributes inspector
D. Attributes inspector, then Identity inspector

59 A scene-based application is active when the user presses the Home button. Ignoring unusual interruptions, which scene-level callback order should the application expect?

Activity life cycle Hard
A. sceneWillEnterForeground(_:) followed by sceneWillResignActive(_:)
B. sceneDidDisconnect(_:) followed by sceneDidBecomeActive(_:)
C. sceneWillResignActive(_:) followed by sceneDidEnterBackground(_:)
D. sceneDidEnterBackground(_:) followed by sceneWillResignActive(_:)

60 An application saves critical user edits only in applicationWillTerminate(_:). Some edits are lost after the system removes the suspended app from memory. Which strategy is correct?

Activity life cycle Hard
A. Save only in sceneDidBecomeActive(_:) because background transitions cannot perform file writes
B. Persist important state as it changes and finalize it when the scene enters the background
C. Keep using termination because iOS always invokes it before reclaiming suspended applications
D. Store edits solely in view-controller properties because suspended memory is permanently preserved