• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 21 pages
Exam (elaborations)

Cse 335 Exam 2 Questions With Answers And Explanations

Document preview thumbnail
Preview 3 out of 21 pages

Cse 335 Exam 2 Questions With Answers And Explanations

Content preview

CSE 335 EXAM 2 QUESTIONS WITH
ANSWERS AND EXPLANATIONS
1. A code review focuses on this situation: A screen duplicates API construction in several button
closures. Which
design decision best addresses it?
A. Perform database mutations directly in body
B. Start duplicate requests on every body evaluation
C. Keep networking and persistence off the View layer
D. Put all URL parsing into Text views
Correct Answer: C. Keep networking and persistence off the View layer
Explanation: Separating data/service work from rendering avoids side effects during view
recomputation and improves testability.
2. A code review focuses on this situation: A history view needs records from one category sorted
newest first.
Which design decision best addresses it?
A. Use a filtered/sorted query
B. Load every record and ignore the filter forever
C. Encode the sort order into the app icon
D. Store a separate database for each sort order
Correct Answer: A. Use a filtered/sorted query
Explanation: Queries should express selection and ordering close to the persistence layer when
appropriate.
3. Tests should replace production data access with a deterministic in-memory implementation.
Which choice is
most appropriate?
A. Duplicate persistence logic in each feature
B. Put all HTTP and database code directly in every View
C. Repository abstraction
D. Use only static global functions with hidden dependencies
Correct Answer: C. Repository abstraction
Explanation: A repository can centralize data access and hide whether data comes from local
storage, network services, or a
combination.
4. A new contact object must be tracked by the app's model container. Which choice is most
appropriate?
A. Insert through the model context and save as appropriate
B. Place the object in an image asset catalog
C. Assign the object only to a local constant
D. Write the object into a navigation title
Correct Answer: A. Insert through the model context and save as appropriate
Explanation: Persistent model objects must be inserted into the data context so the persistence
layer tracks them.
5. A code review focuses on this situation: A feature needs a cancellable asynchronous HTTP
request. Which
design decision best addresses it?
A. AVAudioSession
B. URLSession
C. CoreLocation
D. UserDefaults
Correct Answer: B. URLSession
Explanation: URLSession is the standard networking API for HTTP requests and data tasks.

,6. A code review focuses on this situation: A contact deletion must update the underlying store,
not only the
current array. Which design decision best addresses it?
A. Remove the navigation destination only
B. Hide the row only and leave the object stored
C. Delete the model object through the persistence context
D. Set every property to an empty value
Correct Answer: C. Delete the model object through the persistence context
Explanation: Removing a persistent object requires deleting it from the model context/store, not
merely hiding its view.
7. A detail screen shows cached content while a refresh may independently fail. Which choice is
most appropriate?
A. Represent loading, success, empty, and error states explicitly
B. Treat an empty result as identical to a transport error
C. Use one Boolean for every possible condition
D. Show stale data with no indication of failure
Correct Answer: A. Represent loading, success, empty, and error states explicitly
Explanation: Explicit resource states make asynchronous UI behavior predictable and testable.
8. An app is being revised because of this need: A list should display favorites in alphabetical
order from persistent
storage. Which change is the best fit?
A. Load every record and ignore the filter forever
B. Encode the sort order into the app icon
C. Store a separate database for each sort order
D. Use a filtered/sorted query
Correct Answer: D. Use a filtered/sorted query
Explanation: Queries should express selection and ordering close to the persistence layer when
appropriate.
9. During implementation, this requirement arises: Rapidly changing search text launches a new
request for each
query. What should the developer use?
A. Restart the entire application
B. Block the main thread until all requests finish
C. Let every stale request finish and overwrite newer results
D. Cancel obsolete tasks
Correct Answer: D. Cancel obsolete tasks
Explanation: Cancellation prevents outdated asynchronous work from wasting resources or
racing newer requests.
10. During implementation, this requirement arises: A screen should show only incomplete tasks
ordered by due
date. What should the developer use?
A. Load every record and ignore the filter forever
B. Use a filtered/sorted query
C. Encode the sort order into the app icon
D. Store a separate database for each sort order
Correct Answer: B. Use a filtered/sorted query
Explanation: Queries should express selection and ordering close to the persistence layer when
appropriate.

, 11. A code review focuses on this situation: A remote configuration response should be reused
until its TTL
expires. Which design decision best addresses it?
A. Cache reusable responses with a clear invalidation policy
B. Cache forever with no expiry or versioning
C. Always redownload immutable resources on every redraw
D. Store all response bytes in a UI label
Correct Answer: A. Cache reusable responses with a clear invalidation policy
Explanation: Caching can reduce latency and network use, but cached data needs defined
freshness/invalidation behavior.
12. During implementation, this requirement arises: A user creates a note that must still exist
after relaunch. What
should the developer use?
A. Write the object into a navigation title
B. Insert through the model context and save as appropriate
C. Assign the object only to a local constant
D. Place the object in an image asset catalog
Correct Answer: B. Insert through the model context and save as appropriate
Explanation: Persistent model objects must be inserted into the data context so the persistence
layer tracks them.
13. A coordinator needs to push destinations based on typed route values. Which choice is most
appropriate?
A. Recreate the root view for every detail selection
B. Hard-code destination state in a global variable
C. Use a ZStack as a navigation history
D. A navigation path or value-based destination
Correct Answer: D. A navigation path or value-based destination
Explanation: Value-driven navigation can represent and restore multi-step navigation state
explicitly.
14. An app is being revised because of this need: A newly created task should become part of the
persistent store.
Which change is the best fit?
A. Write the object into a navigation title
B. Assign the object only to a local constant
C. Place the object in an image asset catalog
D. Insert through the model context and save as appropriate
Correct Answer: D. Insert through the model context and save as appropriate
Explanation: Persistent model objects must be inserted into the data context so the persistence
layer tracks them.
15. A background network request finishes and the visible loading state must change. Which
choice is most
appropriate?
A. Mutate UI state from an arbitrary background context
B. Disable concurrency entirely
C. Update UI-observed state on the main actor
D. Store every UI value in UserDefaults
Correct Answer: C. Update UI-observed state on the main actor
Explanation: UI-facing state should be mutated on the main actor to preserve thread-safety
expectations of the UI framework.

Document information

Uploaded on
October 10, 2026
Number of pages
21
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Favorgrades
3.8
(199)
Sold
854
Followers
377
Items
57829
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions