This is very similar to the other answers, but differes in that it does not attempt to instantiate an abstract class.
The three answers that are similar are all using Composition to solve the problem. One calls it a facade, another adapter. I call it proxy. I'm not sure which (if any) is correct. The important fact in all three is that we use Composition instead of inheritance.
Start by creating interfaces.
For example:
public interface iA
{
public void doA();
}
public interface iB
{
public void doB();
}
Alter your abstract classes to implement these interfaces
abstract class A implements iA
{
public void doA()
{
... blah ...
}
}
abstract class B implements iB
{
public void doB()
{
... blah ...
}
}
Create concrete versions of A and B (here I do this as inner classes of C), implement both interfaces in C, and proxy the calls doA() and doB() from the C class to the concrete implementations.
public class C implements iA, iB
{
private ConcreteA cA = new ConcreteA();
private ConcreteB cB = new ConcreteB();
public void doA()
{
cA.doA();
}
public void doB()
{
cB.doB();
}
private class ConcreteA extends A
{
public doA()
{
... blah ...
}
}
private class ConcreteB extends B
{
public doB()
{
... blah ...
}
}