Question 324 of 513
1Z0-829 Java I/O API and Securing Applications Practice Question
A company uses serialization to transfer objects between microservices. To prevent deserialization attacks, they want to restrict which classes can be deserialized. Which approach should be used in Java 17?
⚠ Common exam trap
A common mix-up: candidates confuse `resolveClass` (which loads a class) with `ObjectInputFilter` (which filters class resolution), or they assume `SecurityManager` is still the correct tool for this task despite its deprecation in Java 17.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use ObjectInputFilter with a custom filter
Java 17 provides the `ObjectInputFilter` API (introduced in Java 9) as the standard mechanism to restrict which classes can be deserialized. By setting a custom filter via `ObjectInputStream.setObjectInputFilter()` or a system-wide `jdk.serialFilter` property, you can whitelist or blacklist classes based on patterns, effectively preventing deserialization attacks without modifying the serialization stream itself.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Override resolveClass in ObjectInputStream
Why it's wrong here
While possible, resolveClass is less flexible and not the preferred pattern in Java 17.
- ✗
Use SecurityManager with a policy file
Why it's wrong here
SecurityManager is deprecated and does not provide class-level deserialization filtering.
- ✓
Use ObjectInputFilter with a custom filter
Why this is correct
ObjectInputFilter is the recommended approach to restrict deserialized classes in modern Java.
- ✗
Implement Externalizable and control fields
Why it's wrong here
Externalizable controls serialization but does not prevent deserialization of other objects.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 25, 2026
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.