Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Java
/
Object-oriented programming
Which design best preserves an account invariant that the balance never becomes negative?
from Object-oriented programming
Java 25 LTS
beginner
1 min
Which design best preserves an account invariant that the balance never becomes negative?
Keep the balance private and expose validated deposit and withdrawal operations.
Keep the balance private but provide an unrestricted setter.
Make the balance public and document that callers should be careful.
Return a mutable balance holder so callers can update it efficiently.
Check
Ask AI about this kata
Report an error
next kata
What does this program print?
Predict the output
A new version is available
Reload