Invalid method invocations

Report a typo

There is a class hierarchy that includes three classes:

class Animal {

    protected int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

class Pet extends Animal {

    protected String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

class Cat extends Pet {
    
    protected String color;

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}


Given the following object:

Pet cat = new Cat();


Select all invalid method invocations.

Select one or more options from the list
___

Create a free account to access the full topic