Beta is an interface that contains no methods. Alpha is a class that implements Beta, and contains a method called testIt().
The variable b is an instance of Alpha, but it is
upcast to type Beta. From the compiler's perspective, b is of type Beta, so it contains no methods. Therefore, b.testIt() results in a compile-time error.
In order to call testIt() in object b, you could explicitly downcast it back to type Alpha...
Alpha a = (Alpha) b;
a.testIt();
Or, as Emilio suggested, you could add the method testIt() to the interface Beta. (Note that, since Beta is an interface, all methods are implicitly public and abstract. The compiler would be happy because the method exists in the declared type. And at runtime,
polymorphism would invoke the method implementation in Alpha.)
[ September 12, 2004: Message edited by: marc weber ]