Below is an example of what *not* to do with encapsulation. An IPhone is a Phone which is a Device. Devices already have a field for a Battery. By putting the same field into the IPhone class, it can be confusing when getVoltage() is called.
public class IPhone extends Phone { private Battery b; public IPhone() { b = new Battery(6.0); System.out.println(getBattery()); } }