Visibility Modifiers
Let's start with the most basic tool that Java provides us for enforcing boundaries: visibility modifiers.
Visibility modifiers have been a topic in almost every entry-level job interview I have conducted in the last couple of years. I would ask the interviewee what visibility modifiers Java provides and what their differences are.
Most of the interviewees only list the public, protected, and private modifiers. Almost none know the package-private (or "default") modifier. This is always a welcome opportunity for me to ask some questions about why such a visibility modifier would make sense in order to find out whether the interviewee could abstract the answer from their previous knowledge.
So, why is the package-private modifier such an important modifier? Because it allows us to use Java packages to group classes into cohesive "modules." Classes within such a module can access each other but cannot be accessed from outside of the package. We can...