Question 5
Back to Exercise
How do you make a property read-only to other classes?
- A Make the field public final
- B A private (preferably final) field with a getter and no setter Correct
- C Mark the getter static
- D Use protected
Correct Answer: Option B
A public final field also cannot be reassigned, but it exposes the representation.
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!