| CPSC 329 |
Software Development |
Fall 2026 |
CPSC 329 Review Information — Exam 3
Exam 3 is a written in-class (one hour) exam covering the Observer
pattern, MVC, concurrency and threads, threads in GUI applications,
streams and networking, and client-server architecture and
protocols. Expect primarily short answer questions focusing on
foundational knowledge and underlying concepts. Some questions
focus on definitions and recall while others may ask you to apply
that knowledge to a particular scenario — for example, a short
code excerpt, class design, or protocol to evaluate or improve.
You won't be asked to write complete programs or large sections of
Java code. There are, however, some topics for which Java
constructs or the Java API is part of the foundational knowledge and
you may be asked to write short pieces of code for that material.
Specifics for each topic area are described in that section below.
You may be asked to read Java and JavaFX code.
Most answers should be short — generally 1-3 sentences, or
1-2 sentences per part for a question with several parts. Some
design questions may require longer answers. A list rather than
complete sentences is fine where appropriate. Time is limited, so
don't write more than necessary!
The topics covered on the exam are listed below. The items under
"Self check" are study goals — examples of the kinds of things
you should be able to do, rather than actual exam questions or a
complete list of what the exam might ask. As a starting point for
studying, try to explain each topic without notes (including an
example of your own where appropriate) and then answer the
associated self check items. Finally, formulate (and then answer) your
own questions about each topic. As a pacing guide, you should be
able to start writing answers for definition/recall questions right
away and "apply to a scenario" questions after a minute or two of
thinking.
The Observer Pattern
You won't be asked to write code for this material.
Topics:
- The problem Observer solves
- Observer's intent, structure, and roles
- Designing notifications: push vs pull, granularity options, guidelines
- Pitfalls in using Observer
- Observer in GUI toolkits: event handling
Self check:
- Explain the problem Observer addresses and how it solves it.
- Identify the role each class plays in a given Observer design.
- Describe the operations on the subject and what each does.
- Distinguish push and pull notifications, explain the
advantages and drawbacks of each and choose between them for a
given observer.
- Compare the ways of organizing notifications when observers
care about different kinds of changes and describe the trade-offs.
- Describe the pitfalls of Observer and identify one in a given
code excerpt or scenario.
- Explain how event handling in a GUI relates to the Observer pattern.
Architecture and MVC
You won't be asked to write code for this material or to know
specific JavaFX classes or methods. Structuring an MVC GUI
application is about how the application is organized into classes
and how those classes are connected, not about the JavaFX code that
implements it.
Topics:
- Architectural styles vs. design patterns
- MVC: the responsibilities of the model, view, and controller;
the dependencies allowed between them
- Model state vs. view state
- How a user action flows through MVC
- Benefits and costs of MVC; variations (MVP, MVVM)
- Structuring an MVC GUI application: startup, event handlers,
connecting views and controllers, full vs incremental refresh,
multiple screens, organizing controllers, testing controllers
- Pitfalls in implementing MVC
Self check:
- Distinguish an architectural style from a design pattern and
identify which a given description is.
- Explain whether MVC is an architectural style or a design
pattern.
- Describe the job of the model, the view, and the controller.
- Describe how the model, view, and controller interact and what
each may depend on.
- Given a responsibility in an interactive program, decide
whether it belongs in the model, the view, or the controller, and
justify the choice.
- Distinguish model state from view state and classify given
pieces of state.
- Given a user action, trace it through the model, view, and
controller, naming what each does and in what order.
- Explain the benefits and costs of MVC.
- Compare MVC, MVP, and MVVM.
- Explain what the startup code of an MVC application should and
should not do.
- Explain what a view's event handlers should do and why.
- Explain how the controller should refer to the view and why.
- Compare full and incremental refresh and explain when each is
appropriate.
- Describe the pitfalls in connecting a view to a model and how
to avoid them.
- Explain how an application can switch between screens in one
window and which part of the design should do the switching.
- Compare organizing controllers by responsibility with one
controller per screen.
- Explain how controller logic can be tested without the GUI.
- Given a GUI class design or code excerpt, identify violations of
the MVC separation and describe how to fix them.
- Design an MVC separation for a GUI application.
Threads
You may be asked to read and write code involving the core
elements for working with threads in Java: Runnable and
Thread, the Thread methods listed below, and when
InterruptedException is thrown. You should be able to
write code for creating and starting a thread and for the common
thread patterns listed below.
Topics:
- Why and when programs need more than one thread; concurrency vs.
parallelism
- What a thread is: what each thread has of its own and what
threads share; the kinds of threads in a Java program
- Creating and starting threads and choosing among the
alternatives
- The scheduler and its effect on what a multithreaded program does
- A thread's lifecycle: its states, what moves it between them, and
how a thread ends (including through an uncaught exception)
- Thread methods: start(), run(), sleep(),
join(), isAlive(), interrupt(); why
not stop() or destroy()
- Common thread patterns: pausing and periodic tasks, waiting for a thread to
finish, stopping a thread safely, interruption
- How a program ends; daemon threads
Self check:
- Describe situations in which a program needs to do more than
one thing at once.
- Distinguish concurrency from parallelism.
- Explain what each thread has of its own, what threads share,
and the consequences of that sharing.
- Identify the kinds of threads in a Java program and explain
when a command-line program and a GUI program exit.
- Explain why the output of a multithreaded program can differ
from run to run.
- Describe the steps for creating and starting a thread and
compare the ways of creating one.
- Given code that creates a Runnable or Thread,
determine whether a new thread is actually started.
- Describe the thread states, what moves a thread from one to
another, and which states isAlive() is true for.
- Explain what sleep() does and which thread it affects and
describe the pattern for a periodic task.
- Describe how to wait for a thread to finish and explain when
waiting is needed.
- Explain how a thread should be stopped and describe how to
design a thread so it can be stopped, including addressing any
complications.
- Explain the choices for handling an InterruptedException and
identify an inappropriate one in given code.
- Explain what a daemon thread is and how a program should end
threads that won't finish on their own.
- Explain what happens when a thread throws an exception that it
doesn't catch.
- Write code to create and start a thread for a given task.
- Write the code to wait for a given thread to finish.
- Write the code to pause the current thread.
- Write the code to make a thread stoppable.
Shared Data and Thread Safety
You may be asked to read and write code using volatile and
both forms of synchronized (blocks and methods).
Topics:
- When sharing data between threads is a problem
- Visibility: what can go wrong and how to address it, identifying problems
- Race conditions: what they are, valid vs. invalid results,
atomicity, the common kinds, and finding them
- Mutual exclusion with synchronized: the two forms, lock objects,
what must be protected, and how a class can enforce it
- Thread safety: what it means, its costs, and the thread safety of
library classes
- Deadlock: how it arises, how to avoid it, and how it differs from
a race condition
Self check:
- Explain how work can be divided among threads safely.
- Explain what a visibility problem is and what causes it.
- Explain what volatile guarantees and what it doesn't and
decide whether volatile is sufficient in a given situation.
- Define race condition and explain what makes a result valid or
invalid.
- Given a scenario, write an interleaving of two threads' steps
that produces an invalid result.
- Explain what an atomic operation is and identify which given
operations are atomic.
- Describe the common kinds of race conditions and give an
example of each.
- Explain the role of testing in finding race conditions.
- Explain mutual exclusion and what it guarantees.
- Compare synchronized blocks and synchronized methods —
what lock each uses, what it protects, and when to use each.
- Explain which accesses to shared data must be protected and
with which lock.
- Explain how to enforce mutual exclusion for a class's data.
- Describe what to look for when identifying visibility problems
and race conditions.
- Given a short code excerpt, identify which data is shared and
by which threads, identify any visibility problem or race
condition and describe how to fix it.
- Explain what thread safe means and the costs and benefits of
synchronization.
- Explain whether the Java Collections classes discussed in class are
thread safe and, if not, how to use them with several threads.
- Define deadlock and explain how it can arise.
- Given a scenario or code excerpt, explain if deadlock is
possible and how to prevent it if so.
- Distinguish deadlock from a race condition. Address the cause,
symptoms, and fix.
- Given a short code excerpt with a visibility problem or race
condition, write the code to fix it using volatile, a
synchronized block, or a synchronized method.
Threads in GUI Applications
You won't be asked to write code for this material. For
Task and Platform.runLater, you should know their
purpose and how they behave, but you don't need to know the
specifics of working with them (such as the methods for cancelling
a Task or for providing its results to the UI). For the
timers, you should know what each one is and when to choose one over
another, but you don't need to know the details of using them.
Topics:
- Keeping the UI responsive
- Feedback for long-running work: what kind and how much
- Stale results: the problem, strategies for preventing or
managing them
- Cancelling long-running work, including work replaced by newer work
JavaFX topics:
- The JavaFX Application thread, background threads, and the scene graph
- Task and Platform.runLater: the purpose and
semantics of each, which parts of the work run on which thread, where
changes to the model should happen, what happens if the work throws an
exception, when to use one vs the other
- Timers: Timeline and AnimationTimer vs.
java.util.Timer and your own thread with a sleep loop; when
to use each
Self check:
- Explain what happens to a GUI when an event handler runs for a
long time and why.
- Explain how a GUI program keeps its interface responsive while
slow work is done.
- Given a long-running operation, choose appropriate feedback and
justify the choice.
- Explain what a stale result is, compare the strategies for
dealing with stale results, and choose one for a given scenario.
- Explain what is involved in cancelling long-running work.
- Explain how work that has been replaced by newer work could
still affect the UI and how to prevent it.
- State the rule about which threads may access the scene graph
and explain the reason for it.
- Explain the implications of that rule for work done on a
background thread and identify violations in given code.
- Explain the purpose of a Task and which parts of its
work run on which thread.
- Explain what happens if background work throws an exception
and nothing handles it.
- Explain whether a background thread in a GUI program should be
a daemon thread.
- Explain the purpose and semantics of
Platform.runLater and what it does and doesn't take care
of.
- Explain when to use a Task and when to use
Platform.runLater.
- Explain how a thread reading from a server should handle a
message that changes the model and identify problems in a given
design.
- Compare Timeline, AnimationTimer,
java.util.Timer, and your own thread with a sleep loop,
and choose one for a given periodic task.
Streams
You don't need to know the constructors or methods of specific
stream classes, but you should know the names of the following
classes and when to choose each one: BufferedReader,
PrintWriter, InputStream and OutputStream,
DataInputStream and
DataOutputStream, ObjectInputStream and
ObjectOutputStream, Scanner, FileReader
and FileWriter, FileInputStream and
FileOutputStream.
Topics:
- Streams as an abstraction for input and output; hoses and nozzles;
the steps in working with streams
- Kinds of streams: byte vs. character streams; character sets;
telling them apart by name
- Where streams come from: already-connected and created hoses
- Choosing nozzles for a reading or writing need
- Reading to the end of a stream; closing streams
- Wrapping the same stream more than once vs. stacking nozzles
- Compatibility between writing and reading
Self check:
- Explain what a stream is and the advantage of using streams for
all kinds of input and output.
- Explain the concept of hoses vs. nozzles and identify which of
the classes listed above fall into each category.
- Describe the steps in working with streams.
- Distinguish byte streams from character streams, identify which
a given class is from its name, and explain the role of a
character set.
- Identify the already-connected hoses available in a Java program.
- Describe how to create hoses for files and network connections.
- Given a reading or writing need, choose an appropriate nozzle
class.
- Explain how a program detects the end of a stream when
using BufferedReader.
- Explain which streams a program should close and what closing
a nozzle does.
- Distinguish stacking nozzles from wrapping the same stream more
than once and explain why wrapping the same stream more than once
isn't safe.
- Explain what must match between writing and reading and what
happens if it doesn't.
Network Communication
You don't need to know the constructors or methods of
Socket and ServerSocket other than
accept(), but you should know both class names and the
difference between them.
Topics:
- Sockets, hosts, and ports
- The steps in network communication; the roles of the server-side
and client-side socket classes
- Using streams over a network: message boundaries, flushing,
detecting a closed connection
- Common failures and their symptoms
Self check:
- Explain what a socket is and how a program is found on a
network.
- Describe the steps in network communication and what the
server and the client each do.
- Distinguish ServerSocket from Socket and explain
what accept() does.
- Explain how a receiver can tell where one message ends and the
next begins when messages are sent over a connection.
- Explain when and why a program must flush and what happens if
it doesn't.
- Explain how a program learns that the other side has closed the
connection.
- Given a symptom (an exception or a program that hangs),
identify likely causes.
Concurrency in Clients and Servers
Topics:
- Why servers and clients need threads
- Structuring a server with several clients: what each thread does
and owns
- Shared data on a server, including the connections themselves;
locking and its costs
- Structuring a client that can receive messages at any time,
including a GUI client
- Protocol deadlock
Self check:
- Explain what happens when a server with only one thread has several
clients.
- Describe how a server can handle several clients at once and
what each part is responsible for.
- Identify the data shared by a server's client threads and
explain what could go wrong without synchronization.
- Explain the issues when several threads use the same connection
and how to address them.
- Evaluate the costs of locking on a server and describe a way to
reduce them.
- Explain how a client that can receive messages at any time
should be structured, including in a GUI client.
- Explain what a protocol deadlock is, how it can arise, and how
it differs from deadlock with locks.
Client-Server Architecture
Topics:
- Client-server as an architectural style; the roles of the server
and the client
- Peer-to-peer; trade-offs between the two styles
- Where the model lives: MVC across the network, requests and
reports, the client's copy of the state
- Validation on the client vs. on the server
Self check:
- Explain whether client-server is an architectural style or a
design pattern and identify the style a given system description
exemplifies.
- Explain the role of the server and the role of the client in a
client-server architecture.
- Describe peer-to-peer and how it differs from client-server.
- Explain the trade-offs between client-server and peer-to-peer
and choose between them for a given system, justifying the choice.
- Explain how the MVC roles are divided between server and client
and how Observer applies.
- Distinguish requests from reports and explain which side sends
which.
- Explain the purpose of the client's copy of the state and when
it changes.
- Explain the roles of validation on the client and on the
server, including when a client may refuse to send a request.
- Explain how changes in the server's model reach the clients.
Protocols
You should be able to read sequence diagrams and state diagrams for
a protocol, but you won't be asked to draw them.
Topics:
- What a protocol specifies
- Design choices for message syntax
- Developing a protocol
- Conversation states on the server and on the client
- Sequence diagrams and state diagrams for a protocol
Self check:
- Describe what a protocol specifies, with an example of each
part.
- Compare the ways of marking where a message ends.
- Compare text, binary, and Java-object messages and the ways of
structuring a text message, and choose one for a given situation.
- Explain the purpose of versioning a protocol.
- Explain the purpose of conversation states on the server and on
the client and what the description of each state must address.
- Given a protocol and a scenario, trace the messages exchanged.
- Given a sequence diagram or state diagram for a protocol,
explain what it shows about the conversation.
- Design a simple client-server protocol for a given application.