1Z0-811 Exception Handling and Development Tools Practice Question
A developer encounters a ClassNotFoundException at runtime. The class is present in the source code and compiles fine. Which is the most likely cause?
⚠ Common exam trap
Candidates often confuse a compile-time error (wrong package) with a runtime error (classpath issue), or they mistakenly think that a static initializer failure causes ClassNotFoundException instead of ExceptionInInitializerError.
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
✓
The classpath does not include the directory or JAR containing the .class file.
A ClassNotFoundException occurs when the Java Virtual Machine (JVM) cannot locate the .class file for a referenced class at runtime, even though the source code compiled successfully. Since the class compiles fine, the issue is not with the source code but with the runtime environment — specifically, the classpath does not include the directory or JAR file that contains the compiled .class file. The JVM uses the classpath to search for class files during class loading, and if the path is missing, it throws ClassNotFoundException.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The class is in the wrong package.
Why it's wrong here
A wrong package would cause a compilation error, not a runtime exception.
- ✓
The classpath does not include the directory or JAR containing the .class file.
Why this is correct
ClassNotFoundException occurs when the class definition is not found at runtime, usually due to incorrect classpath.
- ✗
The class is abstract.
Why it's wrong here
Abstract classes can be instantiated through subclasses; being abstract does not cause ClassNotFoundException.
- ✗
The class has a static initializer that fails.
Why it's wrong here
A static initializer failure would cause ExceptionInInitializerError, not ClassNotFoundException.
Go deeper
Related to this question
About these practice questions
One of 481 original 1Z0-811 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.