First question:
The implementation satisfies both contracts, so whether you cast your concrete class to Printable
or Showable
, it will be used just the same. You will notice that there is an "impossible" situation, like this:
public interface Printable{
String print();
}
public interface Showable{
void print();
}
public class Impl implements Printable,Showable{
/*impossible to implement because you cannot have the same method signature with two different return types*/
}
The multiple inheritance would usually imply there is something useful added by each parent. For example, if Printable
would have the method #print
and Showable
would have the method #show
, inheriting them both would add functionality to your program.
If you want to combine functionality from several concrete classes, you might want to look into composition instead of inheritance.
The answer to the second question is more tricky. You can find a longer discussion here. While it would have been possible for the creators of Java to put in such option, it would have opened the door to some pretty messed up code. Think of the example you gave: what if Printable
and Showable
had concrete implementations for the #print
method? Which implementation should the inheriting class have chosen?