Skip to content

Opening book details…

Can I read Java Interfaces in Animal Classes on EtoBox?

Java Interfaces in Animal Classes by saber is a document available to read on EtoBox.

What is Java Interfaces in Animal Classes about?

The document discusses different options for adding "pet behaviors" like playing to animal class hierarchies in Java. It considers adding a play() method to the base Animal class, but rejects this due to the method also applying to non-pet classes like Lion. It also rejects using multiple inheritance to add a Pet interface. The best solution is to define Pet as an interface containing play() and other pet methods, and have classes like Dog and Cat implement this interface to define pet-specific behavior. In

Author
saber
Language
EN