Question: I have an app ready and running in the Google Play store, now i am implementing fragments.

so,i already have a class A which extends B with some methods, now i have class which C extends FragmentActivity, so now i need use the same methods as in class A but here since i am extending FragmentActivity i cannot make use of class B, so here there are duplicate methods which are same as class A but i need to reuse the methods.

This below example shows my situation:

Eg:

**Current implementation**

```
class A extends B{

one();
two();

}

```

**After integrating fragments,**

Eg:

```
class C extends FragmentActivity{

one();// same methods as in class A
two();// same methods as in class A

}

```

1) What is the best way to re-use the methods in this case and how?

2) I have approach in my mind like creating a class and make the methods as static and re-use the methods in both A and C class, but is my approach good and can i make the methods as static and is it a good approach ?

3) Another approach that i have thought of **"Strategy Pattern".**

```
Eg:
class A extends ApiClass {
   private ClassContainingDupMethod strategy;
}

class N extends AnotherApiClass {
   private ClassContainingDupMethod strategy;

   public methodCallingDupMethod(){
      strategy.dupMethod();
   }
}

class ClassContainingDupMethod{
   public dupMethod(){;}
}

```

Is the **"Strategy Pattern".** a good approach ? as i need to create object of common class in both the classes.

Any suggestions on this would be appreciated.

Answer: 
You should start with what Babibu said - simple composition.

When you master this there are other technics too. For instance dependency injection looks like something that could be used here. 
Simple case would go something like this. Define interface B instead of a class B. Pass interface B as a parameter during initialization of C, have it as internal variable b and call b.one() and b.two(). 
You will have to create an object A that implements B outside of C scope and pass it in during activity C initialization. 
Advantage: C doesn't need to know how to create A, you can change it later to AA or AAA and never touch your activity again as long as AA and AAA implement B. You don't have to retest C.
Strategy Pattern or 'wrapper' is the best choice. And I think Juan Sánchez's solution is better than Babibu's one. As in Babibu's code, class A should not be dependent on D. Be dependent on an interface is better.
In your code, if class A contains some attributes or some actions that class C doesn't need, you can refactor your code like below. Otherwise Juan's solution is enough.
I've drawn an UML image for this situation, but I've no enough reputation to post it:-(
Code is like this:

```
interface IAction
{
   public void actionA();
}

class A extends B implements IAction
{
   private IAction action;
   public void actionA() {
      action.actionA();
   }
}

class C extends FragmentActivity implements IAction
{
   private IAction action;
   public void actionA() {
      action.actionA();
   }
}

class D implements IAction
{
   public void actionA() {
   // put implementation here
   }
}

```