I have an Interface MyInterface with two methods doSomething() and doSomethingElse().
I have an Abstract public class A that implements this interface. I Have a class C that extends class A and therefore implements the interface's methods as well. On the main method I assign the object of class C to a MyInterface reference like: MyInterface myiface = new C();
The problem is that if I add some methods in either class (abstract or concrete) I cannot call the method through the reference myiface. I have to downcast it first. Shouldn't I be able to polymorphically access the class as it is shown in the book Java SE8 for programmers of Deitel (Chapter 10 Polymorphism and Interface) ?
Think of it like this...imagine your MyInterface is named 'Animal' and you have two classes implementing it, named 'Dog' and 'Cow'. just because they are both animals you wouldn't expect the Dog to suddenly give milk, right? In this analogy giveMilk() is a method only implemented by the Cow class.
do you get it?