+ Start a Discussion
Ram ChaturvediRam Chaturvedi 

Can we use hybrid inheritance in apex ? Any simple Ecample ?

User-added image
Best Answer chosen by Ram Chaturvedi
Denis VakulishinDenis Vakulishin
I think diagram will look like 
public class TestInterface {
	public interface IOne
    {
        void MethodOne();
    }
    public interface ITwo extends IOne
    {
        void MethodTwo();
    }
    public virtual class ClassOne implements IOne
    {
        public void MethodOne(){}
    }
    public class ClassTwo extends ClassOne implements ITwo
    {
        public void MethodTwo(){
            MethodOne();
        }
    }
}


All Answers

Denis VakulishinDenis Vakulishin
Hi, 
This is for class inheritance 
public virtual class BaseClass 
{  
   ADVProcess m_ADVProcess;
  
   //Constructor
   public BaseClass()   
   {     
   }
   
   public virtual string PublicMethod()
   {   
    
   }  
   
   
   protected virtual string ProtectedMethod()
   {
   	
   private virtual string PrivateMethod()	   
   {
   	
   }

}  

//Child Class 
public virtual class ChildClass extends BaseClass
{        
   //Constructor
   public ChildClass()   
   {     
   	
   }     
   public override string PublicMethod(){}

   protected override string ProtectedMethod(){}
  
}

Also check this doc's article 
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_example.htm
Ram ChaturvediRam Chaturvedi
can we can use above scenrio which i had shown in diagram . ? 
your link is for multilevel inheritance . 
Denis VakulishinDenis Vakulishin
I think diagram will look like 
public class TestInterface {
	public interface IOne
    {
        void MethodOne();
    }
    public interface ITwo extends IOne
    {
        void MethodTwo();
    }
    public virtual class ClassOne implements IOne
    {
        public void MethodOne(){}
    }
    public class ClassTwo extends ClassOne implements ITwo
    {
        public void MethodTwo(){
            MethodOne();
        }
    }
}


This was selected as the best answer
Denis VakulishinDenis Vakulishin
Hi, 
Did it help you ?
If yes could you mark it as Best Answer ?
if no feel free to ask additional questons.
Thanks
Ram ChaturvediRam Chaturvedi
Thanks Denis