There are library classes B and C, both inherit from class A. I have 2 classes that extend B & C, namely MyB & MyC.
    A
   / \    
  B   C 
 /     \
MyB   MyC
MyB & MyC share lots of common code and they are only slightly different. 
I want to get rid of duplicate code, how can I do this in java? In C++ it would be possible by creating a common base class and putting everything that is common in it as follows:
    A
   / \  
  B   C 
   \ /
  MyBase
   / \
 MyB MyC
 
     
     
     
     
     
    