Question 19
Back to Exercise
Why does System.out.println(count); in static main fail when count is an instance field?
- A count must be public
- B main is static and has no object, so there is no instance whose count could be read Correct
- C println cannot print fields
- D count must be final
Correct Answer: Option B
Create an object, or make the field static if it truly belongs to the class.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!