Is the following correct:
-Grass and Plant have nothing to do here
-Sheep is a animal and eats plants (why is there "<sheep>" as Herbivore type?). Sheep eat sheep?
-Wolf is a animal and eats meat (sheeps)
-Interfaces Carnivores and Herbivores are of type hungry, so they are hungry
I know this is from the self-test in KB's book.
What is your question regarding to this self
test question? If you don't understand the explanation in the self-test, let us know.
Why is there <Sheep> as Herbivore type?
Herbivore <E extends Animal> means Herbivore take an Animal as its generic parameter. Sheep is an animal. So, Herbivore<Sheep> compiles.