How to call abstract class methods in Salesforce?

How to call abstract class methods in Salesforce?

Abstract Class:


public abstract class SampleAbstract
{
    public Task newTask;
    public void createT(Id caseId, Id accountId)
    {
        newTask = new Task();
       
        methodX();
        methodY();
    }
   
    public abstract void methodX();
    public abstract void methodY();
}


Class extending Abstract class:


public class Sample extends SampleAbstract {  
   
    public sample() {
    }
   
    public override void methodX(){
    }
   
    public override void methodY(){
    }  


}


Test class:


@isTest
private class AbstractTest{
    static testMethod void test(){
        Sample sa = new Sample();  
           
        Id caseId;
        Id accountId;
        sa.createT(caseId, accountId);  
    }
}

Leave a Reply