Protected variables and classes can only be accessed by the class that created them, the creator's subclasses, and classes in the same Java package. Public variables and classes are accessible by all classes. By default, entities in a class can be accessed by code within the class that defines them, or by a class in the same package as the class that defines them. The access levels described here help address this concern. Garbage collection automatically frees memory when it is no longer needed.
Type safety is certainly a key language feature in Java.
For now, suffice it to say that making sure the VM does not become confused about the kinds of objects it is using is essential. This is pretty obvious if you think about the fact that the security model itself is a collection of classes with certain types. That is up to the Java sandbox. All rights reserved.