private Animal[] myFarm = new Animal[4]; public Farm(){ myFarm[0] = new Cow(); myFarm[1] = new Chick(); myFarm[2] = new Pig(); myFarm[3] = new NamedCow("Elsie"); } public void animalSounds(){ Animal temp; for (int i = 0; i < myFarm.length; i++){ temp = myFarm[i]; System.out.println(temp.getType() + " goes " + temp.getSound()); }