1Z0-811 Java Basics and Syntax Practice Question
A class defines a static variable initialized at declaration: static int count = 10;. A static method attempts to modify it: count = 20;. Which statement is true?
⚠ Common exam trap
Oracle often tests the misconception that static methods cannot access static variables, or that static variables are implicitly final, leading candidates to choose compilation error or read-only options.
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 variable can be changed to 20
Static variables belong to the class, not instances, and can be accessed and modified by static methods. The assignment `count = 20;` is valid and changes the value from 10 to 20 at runtime.
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 variable cannot be accessed from a static method
Why it's wrong here
Static methods can access static variables directly.
- ✗
The code causes a compilation error
Why it's wrong here
Static methods can access static variables.
- ✓
The variable can be changed to 20
Why this is correct
Static variables are modifiable unless declared final.
- ✗
The variable is read-only
Why it's wrong here
No final keyword, so it is not read-only.
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.