how to achieve encapsulation in java