Question: I have an Object which comes and has a bunch of public attributes and no getters and setters. BAD! 
So I created a class with the attributes and created getters and setters for them. My plan is to wrap the object in my class so it means no direct access to attributes.
I'm kind of unsure how to do this. I understand casting fine.
How exactly could I wrap the class with my safe class with getters and setters and gain access to the attributes via my getters and setters?

Answer: 
Maybe like this?

```
class MyCar implements ICar{

    private final Car car;
    public MyCar(Car car)
    {
         this.car = car;
    }

    public string getModel()
    {
          return car.model;
    }

    public void setModel(string value)
    {
          car.model = value;
    }

}

```

now instead of passing around an instance of `Car`, you can either pass around `MyCar` instance which has getters and setters or a reference to `ICar` which will let you control exactly what you would like to expose (for example you could just expose the getters).
Use composition. If you class with public properties is called Exposed, just do

```
public class ExposedProtector {
    private Exposed exposed;  // private means it can't be accessed directly from its container

    //public/protected methods here to proxy the access to the exposed.

}

```

Note that nothing will prevent other people from creating instances of Exposed. You will have to modify the actual exposed class itself, which might be the better way to do this, if possible.

You should look at the java access modifiers. There are varying levels of access, from private to protected to public.