Apart from the points discussed in other answers and comments, which state that for your specific case, it is fine to have independent methods, nevertheless there may be cases where you have a one or more methods which are implemented by independent classes, but are common behavior of these classes. For this purpose, an interface is what Java provides: If several classes have similar behavior, but independent inheritance hieararchies.
While a class can only inherit from one parent class, it can implement several interfaces. In its pure sense, an interface does not have any implementation, but just declare abstract methods which must be implemented by all classes implementing it. And you still can define variables of the interface type, and then assign all types of classes implementing this interface tto the variable, and call the interface methods on the interface variable.
If you e. g. have an interface
interface HasName {
void change_name(newName);
}
then both classes could implement that. A more meaningful example would e. g. be two classes Dog
and Girl
, both implementing the HasName
interface, but not being the ancestor of each other neither having a common ancestor.