1Z0-811 What is Java Practice Question
A developer is tasked with deploying a Java application to a customer's server. The customer has only a JRE installed and no internet access. The application uses Java NIO and requires reading configuration files from the classpath. The application compiles and runs fine on the developer's machine which has JDK 11. However, when deploying the compiled JAR to the customer's JRE 11, it throws a 'NoClassDefFoundError' for a class that is part of the JDK's internal API (e.g., com.sun.nio.file.SensitivityWatchEventModifier). The developer is confused because the class is in the standard library. Which action should be taken to resolve the issue?
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
✓
Modify the code to use a public API from the standard library
The issue is that the code uses an internal JDK API (com.sun.nio.file.SensitivityWatchEventModifier), which is not guaranteed to be available in all JRE distributions and is encapsulated in Java 9+. The proper fix is to modify the code to use a public, supported API from the standard library (e.g., java.nio.file.StandardWatchEventKinds). Option A is incorrect because recompiling with a lower target version would still use the internal API, and the target version does not affect encapsulation. Option B is incorrect because the missing class is not a separate JAR; it's part of the JDK internal modules and not available in the JRE's classpath. Option D is incorrect because installing the JDK would expose the internal class but is not a proper solution; it ties the application to a specific JDK implementation and may violate encapsulation in future releases.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Recompile with a lower target version
Why it's wrong here
This does not address the use of internal APIs; they remain inaccessible.
- ✗
Add the missing JAR file to the classpath
Why it's wrong here
The class is not in a separate JAR; it is in the JDK's internal modules.
- ✓
Modify the code to use a public API from the standard library
Why this is correct
Internal APIs are not accessible; use public alternatives.
- ✗
Install the JDK on the customer's server
Why it's wrong here
This would expose the internal class but is not a recommended solution; the JRE should suffice.
Visual reference
Go deeper
Related to this question
About these practice questions
This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-811 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-811 exam.