1Z0-811 Exception Handling and Development Tools Practice Question
Exhibit
Exception in thread "main" java.lang.NullPointerException
at com.example.MyClass.methodA(MyClass.java:25)
at com.example.MyClass.main(MyClass.java:10)Refer to the exhibit. A Java program throws a NullPointerException. Which is the most likely cause?
⚠ Common exam trap
Oracle often tests the distinction between compile-time errors (syntax, imports, classpath) and runtime exceptions (NullPointerException), trapping candidates who confuse a missing import or classpath issue with a null reference problem.
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
✓
An object not initialized before use
A NullPointerException is thrown when the JVM attempts to access a method or field on an object reference that is null. The most common cause is that the object was declared but never instantiated (e.g., `String s; s.length();`). This is a runtime exception, not a compile-time error, so it occurs during execution when the reference variable points to null.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
An object not initialized before use
Why this is correct
NullPointerException occurs when invoking a method or field on a null reference.
- ✗
A syntax error in the try block
Why it's wrong here
Syntax errors are caught at compile time.
- ✗
Incorrect classpath preventing class loading
Why it's wrong here
Classpath issues lead to ClassNotFoundException or NoClassDefFoundError, not NullPointerException.
- ✗
A missing import statement in the source code
Why it's wrong here
Missing imports cause compilation errors, not runtime NullPointerException.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.