why are variables private in java To achieve encapsulation and this can't be accessible outside the class. This doesn't mean programmer can't change the source code.