• 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 Midterm Exam Questions With Answers And Explanations

Document preview thumbnail
Preview 3 out of 21 pages

Cse 335 Midterm Exam Questions With Answers And Explanations

Content preview

CSE 335 MIDTERM EXAM QUESTIONS WITH
ANSWERS AND EXPLANATIONS
1. A midterm-style integration review identifies this requirement: A view model should use a
mock API client during
tests and a real client in production. Which recommendation is strongest?
A. Create every dependency inside every method
B. Dependency injection
C. Duplicate service logic in each view
D. Use hidden global state for all services
Correct Answer: B. Dependency injection
Explanation: Dependency injection makes dependencies explicit and replaceable, improving
modularity and testability.
2. During regression testing of the first half of the course, this requirement becomes important: A
request body
should be encoded from a Swift value into JSON. Which implementation choice is most
defensible?
A. NotificationCenter
B. GeometryReader
C. Codable
D. NSLock
Correct Answer: C. Codable
Explanation: Codable supports structured encoding/decoding between Swift models and formats
such as JSON when representations
match.
3. During regression testing of the first half of the course, this requirement becomes important: A
screen
constructs its own observable view model and must keep that same instance across body
recomputations. Which
implementation choice is most defensible?
A. @StateObject
B. @Environment
C. @Binding
D. @ObservedObject
Correct Answer: A. @StateObject
Explanation: @StateObject is used when a view creates and owns the lifetime of an observable
reference-type model.
4. During regression testing of the first half of the course, this requirement becomes important: A
notes app should
remain usable in airplane mode and reconcile edits when online. Which implementation choice is
most defensible?
A. Discard every local edit when connectivity drops
B. Offline-first synchronization with conflict rules
C. Block the UI until the server responds
D. Assume the network is always available
Correct Answer: B. Offline-first synchronization with conflict rules
Explanation: Offline-capable apps need a local source, queued/synchronized changes, and explicit
conflict resolution semantics.

,5. While combining earlier course features, the team must handle this case: The app must ask for
confirmation
before permanently deleting a record. What is the best design choice?
A. ScrollView
B. .sheet
C. NavigationLink
D. .alert
Correct Answer: D. .alert
Explanation: Alerts are suited to short, interruptive messages or confirmations requiring
immediate acknowledgment or choice.
6. While combining earlier course features, the team must handle this case: A reference-data
endpoint changes
rarely and can be reused for a period. What is the best design choice?
A. Cache forever with no expiry or versioning
B. Store all response bytes in a UI label
C. Always redownload immutable resources on every redraw
D. Cache reusable responses with a clear invalidation policy
Correct Answer: D. Cache reusable responses with a clear invalidation policy
Explanation: Caching can reduce latency and network use, but cached data needs defined
freshness/invalidation behavior.
7. A developer is asked to correct this design concern: A button needs a block of code to run
when it is tapped.
Which approach should be selected?
A. A property wrapper
B. A build scheme
C. A module import
D. A closure
Correct Answer: D. A closure
Explanation: Closures are executable blocks that can be passed around and invoked later,
making them useful for callbacks and
higher-order operations.
8. A developer is asked to correct this design concern: A list loads remote data and needs
separate progress,
empty-result, success, and error presentations. Which approach should be selected?
A. Treat an empty result as identical to a transport error
B. Represent loading, success, empty, and error states explicitly
C. Use one Boolean for every possible condition
D. Show stale data with no indication of failure
Correct Answer: B. Represent loading, success, empty, and error states explicitly
Explanation: Explicit resource states make asynchronous UI behavior predictable and testable.
9. A midterm-style integration review identifies this requirement: A toolbar row should keep a
title at the leading
edge and an action at the trailing edge. Which recommendation is strongest?
A. Divider
B. AnyView
C. Spacer
D. Group
Correct Answer: C. Spacer
Explanation: Spacer expands to consume available layout space and can push neighboring views
apart.

, 10. During regression testing of the first half of the course, this requirement becomes important:
A feature needs
one interface for cached and remote user profiles. Which implementation choice is most
defensible?
A. Put all HTTP and database code directly in every View
B. Use only static global functions with hidden dependencies
C. Repository abstraction
D. Duplicate persistence logic in each feature
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.
11. A developer is asked to correct this design concern: An icon and its text label should appear
side by side.
Which approach should be selected?
A. HStack
B. ZStack
C. Form
D. VStack
Correct Answer: A. HStack
Explanation: HStack arranges child views horizontally.
12. A midterm-style integration review identifies this requirement: A repository performs two
asynchronous service
calls sequentially. Which recommendation is strongest?
A. async/await
B. Busy-wait on the main thread
C. Spin in a while loop until the response arrives
D. Block with a long synchronous sleep
Correct Answer: A. async/await
Explanation: async/await expresses asynchronous work without blocking the caller thread while
waiting for completion.
13. A developer is asked to correct this design concern: Each copied coordinate value should be
independent after
assignment. Which approach should be selected?
A. A struct
B. A global singleton
C. A class only
D. A protocol extension only
Correct Answer: A. A struct
Explanation: Structs have value semantics and are commonly suitable for lightweight model
values in Swift.
14. While combining earlier course features, the team must handle this case: Rapidly changing
search text
launches a new request for each query. What is the best design choice?
A. Block the main thread until all requests finish
B. Cancel obsolete tasks
C. Let every stale request finish and overwrite newer results
D. Restart the entire application
Correct Answer: B. Cancel obsolete tasks
Explanation: Cancellation prevents outdated asynchronous work from wasting resources or
racing newer requests.

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
6 days 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