So as I understand, Goat class has no problem with a code, I want to assign the first two elements from a new object, but I am not sure why it gives an runtime error
class Pet {
public String name;
public boolean indoor;
public Pet(String name, Boolean indoor) {
this.name = name;
this.indoor = indoor;
}
public String toString(){
return name + ", " + indoor;
}
}
class Goat extends Pet {
public int age;
public String diet;
public Goat(String name, boolean indoor, int age, String diet) {
super(name, indoor);
this.age = age;
this.diet = diet;
}
Here is the test code and error