Why assign a subclass object to a superclass reference? [duplicate]
问题 This question already has answers here : What does it mean to “program to an interface”? (31 answers) Closed 5 years ago . Animal is a superclass Feline is a subclass of Animal Cat is a subclass of Feline Canine is a sublcass of Animal Dog is a subclass of Canine All of the classes have their own eat() method that outputs: "(class) is eating" I've already tried creating an array of Animals, looping through them, and calling the eat() method, which outputs the proper output for each given