why i cant access field in child class when using inheritance?

hey guys. can smb explain this error? i dont understand what im doing wrong:
public class Animal {
    private String name;
    private int age;
    ///getters and setters
}
public class Dog extends Animal {
    String breed;
    //getters and setters
}
public static void main(String[] args) {
        Animal animal = new Animal();
        animal.setAge(123);
        animal.setName("Animal");

        Animal dog1 = new Dog();
        dog1.setAge(111);
        dog1.setName("Max");
        dog1.setBreed("Boxer");//error

        Dog dog2 = new Dog();
        dog2.setAge(222);
        dog2.setName("Rex");
        dog2.setBreed("Pitbull");
    }

thanks in advance
Was this page helpful?