how can i define a class which defines the object which is encapsulated and the attributes protected from external access, and their value retrieved and defined by public methods in java